/TwitchUrbanDictionary

Twitch Bot to look up urban dictionary definitions and examples.

Primary LanguagePythonMIT LicenseMIT

TwitchUrbanDictionary

Twitch Bot to look up urban dictionary definitions and examples.


Explanation

When the bot has started, it will start listening to chat messages in the channel listed in the settings.txt file. Whenever a user types !urban <term> in chat, the bot will respond with top Urban Dictionary's definition of that word. Similarly, whenever a user types !example <term> in chat, the bot will respond with the example shown in the top example as displayed on Urban Dictionary.

Because both the definitions and examples can be quite long, it is possible to set a max character count. The bot will cleverly cut off separate sentences rather than cutting off right at the character limit. This does mean that the bot always shows at least one sentence, which may cross the character count limit.

The bot has a configurable cooldown attached, to prevent spam in chat.


Usage

Command:

!urban <term>

For example:

!urban hello
Hello: a very offensive curse word.

Anyone can use this command.

Command:

!example <term>

For example:

!example hello
What the hello.

Anyone can use this command.


Settings

This bot is controlled by a settings.txt file, which looks like:

{
    "Host": "irc.chat.twitch.tv",
    "Port": 6667,
    "Channel": "#<channel>",
    "Nickname": "<name>",
    "Authentication": "oauth:<auth>",
    "MaxCharacters": 150,
    "Cooldown": 30
}
Parameter Meaning Example
Host The URL that will be used. Do not change. "irc.chat.twitch.tv"
Port The Port that will be used. Do not change. 6667
Channel The Channel that will be connected to. "#CubieDev"
Nickname The Username of the bot account. "CubieB0T"
Authentication The OAuth token for the bot account. "oauth:pivogip8ybletucqdz4pkhag6itbax"
MaxCharacters The maximum amount of characters the bot should aim to make the results. Might cross this amount if the first sentence is already longer than this amount. 150
Cooldown Cooldown in seconds between uses of the bot, to prevent spam in chat. 30

Note that the example OAuth token is not an actual token, nor is the OWMKey an actual API key, but merely a generated string to give an indication what it might look like.

I got my real OAuth token from https://twitchapps.com/tmi/.


Requirements

Among these modules is my own TwitchWebsocket wrapper, which makes making a Twitch chat bot a lot easier. This repository can be seen as an implementation using this wrapper.


Other Twitch Bots