/botly/client.py (e65066b566b7171dfa89443db2c080450f6b40b9) (2130 bytes) (mode 100644) (type blob)
#!/usr/bin/env python
"""Inherits from Discord client. Handles events and pass them to Botly."""
import asyncio
import discord
class Client(discord.Client):
"""Inherits from discord.client. Used for communication with server."""
def __init__(self, bot):
self.bot = bot
super(Client, self).__init__(max_messages=bot.settings.get_int(
'CacheMaxMessages'))
@asyncio.coroutine
def on_ready(self):
self.bot.print('Bot ready.')
server = None
for s in self.servers:
server = s
self.bot.set_bot_info(self.user, server)
yield from self.bot.react_to('on_ready')
@asyncio.coroutine
def on_typing(self, channel, user, when):
if user != self.user:
yield from self.bot.react_to('on_typing', channel=channel,
user=user, when=when)
@asyncio.coroutine
def on_reaction_add(self, reaction, user):
if user != self.user:
yield from self.bot.react_to('on_reaction_add', reaction=reaction,
user=user)
@asyncio.coroutine
def on_reaction_remove(self, reaction, user):
if user != self.user:
yield from self.bot.react_to('on_reaction_remove',
reaction=reaction, user=user)
@asyncio.coroutine
def on_message_edit(self, before, after):
if before.author != self.user:
yield from self.bot.react_to('on_message_edit', message=before,
after=after)
@asyncio.coroutine
def on_message_delete(self, message):
if message.author != self.user:
yield from self.bot.react_to('on_message_delete', message=message)
@asyncio.coroutine
def on_message(self, message):
if message.author != self.user:
yield from self.bot.react_to('on_message', message=message)
@asyncio.coroutine
def on_member_update(self, before, after):
yield from self.bot.react_to('on_member_update', before=before,
after=after)
def run(self):
super(Client, self).run(self.bot.settings.get_string('DiscordToken'))
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
10175 |
e454a52586f29b8ce8a6799163eac1f875e9ac01 |
LICENSE |
100644 |
blob |
912 |
43cc367ee8608a8760e6665ac29c411d58dc8b99 |
README.md |
040000 |
tree |
- |
66dcfaf2ba5cd5742f36e01d7785daf5113c2107 |
botly |
100644 |
blob |
172 |
3f148ab99d152565c46e51fd45e51030417f7faa |
example.py |
040000 |
tree |
- |
e05b34e00f419ee6a20bf1bb6a0603727b1b4399 |
examplebot |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/detche/Botly
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/detche/Botly
Clone this repository using git:
git clone git://git.rocketgit.com/user/detche/Botly
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main