Categorygithub.com/flameinthedark/dtbot
repositorypackage
0.0.0-20200828124659-e7fbf997b276
Repository: https://github.com/flameinthedark/dtbot.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

Discord Tools Bot

Go report Build Status Scrutinizer Quality Score FOSSA Status Discord Bots

Musor stats on Discord Bot List

Documentation

Used APIs and external software

Bot's features

  • Shows weather
  • Translate words
  • Shows news
  • Shows currency
  • Makes polls
  • Plays music from Youtube
  • Plays music from online radio stations
  • Announcing if Twitch stream is started
  • Greetings new users

How to use

Bot commands

To use the !b or !cron commands you need to create a guild role named bot.admin and add it to you!

CommandDescription
!v joinAdd bot into you voice channel
!v leaveRemove bot from voice channel
!b clear [from_num]Remove bot's messages !b clear or !b clear 3 removes all messages from 3rd message
!b setconf [parameter] [value]Sets the bot configuration for your channel.
!helpShows help
!help [command]Detail help !help y
!help bot.adminShows help how get bot.admin role
!play [youtube_url]Adds track (or playlist) in queue and start playing
!y add [song]Adds song from youtube or soundcloud
!y clearRemoves all songs from queue
!y playStarts playing queue
!y stopStops playing queue
!y skipSkipping one song
!y listList of songs in queue
!r play [radio_station]Plays specified network radio station !r play http://air2.radiorecord.ru:9003/rr_320
!r stopStops radio
!w [place]Shows the weather in a specified location !w New York
!n [category]Displays news in the specified category !n technology
!t [target_lang] [text]Translator !t ru Hello world
!cShows currencies (default from config)
!c listShows list of available currencies
!c [currency]Shows specified currency !c USD EUR
!p new [fields]Creates new poll !p new field one | field two | field three
!p vote [field_num]Votes in poll
!p endEnds poll and shows results
!m [map/sat] [location]Sends location image from yandex map !m map New-York or !m sat New-York
!cron add [cron_time] [command]Creates cron job for command !cron add 0 0 12 * * * !w Chelyabinsk - everyday in 12:00 UTC 0 use command !w
!cron listShows cron jobs
!cron remove [id]Removes cron job by ID !cron remove 1
!geoip [some_ip_address]Shows geographic information about IP
!twitch add [twitch_login]Adds streamer in announcer
!twitch remove [twitch_login] [custom_announce_message]Removes streamer from announcer (custom message is optional)
!greetings add [text]Adds new greetings message with specified text
!greetings removeRemoves greetings message
!greetings testSends you a greetings message

Set config parameters

ParameterDescription
general.language [string]Sets bot language
general.timezone [num]Sets bot timezone
general.nick [string]Sets bot nickname
embed.color [hex color like #007700]Sets bot embed color
news.country [string]Sets bot news country
weather.city [string]Sets default city for weather

Build for docker

Easy way to build docker image for Ubuntu:

Install MongoDB and set environment variable with mongo connection string

export MONGO_CONN=mongodb://user:[email protected]/dtbot

Clone repository and move inside app directory.
Compile app with command:

go build

Create config.toml file from sample sample.config.toml

[weather]
# Old weather API token (deprecated and unused now)
WeatherToken = "OpenWeatherMap API Token"
# Default forecast city
City = "Moscow"

[news]
ApiKey = "Api key from Newsapi.org"
Country = "us"
Articles = 5

[translate]
ApiKey = "Yandex Translate API key"

[general]
GeonamesUsername = "Username from Geonames.org"
Language = "en"
# UTC 0 + Timezone
Timezone = 5
Game = "Half-Life 3"
# Default embed color (Hex color converted to int)
EmbedColor = 4039680
ServiceURL = "https://youtube.com"
MessagePool = 10
DatabaseName = "dtbot"
GeocodingApiKey = "yandex_geocode_api_key"

[currency]
Default = ["USD", "EUR"]

[metrics]
# InfluxDB connection address
Address = "http://some_server.com:8086"
Database = "dtbot"
User = "user"
Password = "password"
# Discord Bot List
[dbl]
Token = "discordbots.org_bot_token"
# Twitch announcer
[twitch]
ClientID = "twitch_application_client_id"
# Weather API
[darksky]
Token = "darksky_api_token"

Make (or use my) Dockerfile:

FROM ubuntu:18.04
RUN apt-get update
RUN apt-get install -y wget ca-certificates ffmpeg python
RUN wget https://yt-dl.org/downloads/latest/youtube-dl
RUN chmod a+rx youtube-dl
COPY . .
ENTRYPOINT ["./dtbot"]

Build docker image

docker build -t dtbot .

Add environment variable BOT_TOKEN with token of discord bot.
And run container:

docker run -d --restart always -e BOT_TOKEN=$BOT_TOKEN -e MONGO_CONN=$MONGO_CONN --name dtbot dtbot:latest