From 7b74cf167ec5dcf72f178ae7f2518f88c7027be9 Mon Sep 17 00:00:00 2001 From: pocketjawa Date: Tue, 21 Feb 2017 04:27:12 +0000 Subject: [PATCH] Initial commit --- config.cfg | 6 ++++++ pocketbot.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 config.cfg create mode 100644 pocketbot.py diff --git a/config.cfg b/config.cfg new file mode 100644 index 0000000..c728f0e --- /dev/null +++ b/config.cfg @@ -0,0 +1,6 @@ +[configuration] +#CONFIGURATION +#Config for the Discord pocketbot (https://git.pocketjawa.com/pocketjawa/discord-pocketbot) + +#Discord client token +token: \ No newline at end of file diff --git a/pocketbot.py b/pocketbot.py new file mode 100644 index 0000000..132ffa2 --- /dev/null +++ b/pocketbot.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3.4 +import discord +import asyncio +import configparser + +#Import config file +config = configparser.ConfigParser() +config.read("/srv/discord-pocketbot/config.cfg") + +token = config.get("configuration", "token") + +client = discord.Client() + +@client.event +@asyncio.coroutine +def on_ready(): + print('Logged in as') + print(client.user.name) + print(client.user.id) + print('------') + +@client.event +@asyncio.coroutine +def on_message(message): + if message.content.startswith('!maki'): + yield from client.send_message(message.channel, 'http://maki.pocketjawa.com/monday.png') + elif message.content.startswith('!sleep'): + yield from asyncio.sleep(5) + yield from client.send_message(message.channel, 'Done sleeping') + + +client.run(token) \ No newline at end of file