/botly/comm.py (66f208591f00caf14963df162edc1690aef322af) (1506 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 Comm(discord.Client):
"""Inherits from discord.client. Used for communication with server."""
def __init__(self, bot):
self.bot = bot
super(Comm, self).__init__(max_messages=bot.settings.get_int(
'CacheMaxMessages'))
async def on_ready(self):
print('Bot ready. Press Ctrl+C to shutdown.')
self.bot.set_whoami(self.user)
await self.bot.react_to('on_ready')
async def on_typing(self, channel, user, when):
if user != self.user:
await self.bot.react_to('on_typing', channel=channel, user=user,
when=when)
async def on_message_edit(self, before, after):
if before.author != self.user:
await self.bot.react_to('on_message_edit', message=before,
after=after)
async def on_message_delete(self, message):
if message.author != self.user:
await self.bot.react_to('on_message_delete', message=message)
async def on_message(self, message):
if message.author != self.user:
await self.bot.react_to('on_message', message=message)
async def on_member_update(self, before, after):
await self.bot.react_to('on_member_update', before=before,
after=after)
def run(self):
super(Comm, self).run(self.bot.settings.get_string('DiscordToken'))
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
896 |
ac3944627b46e5914bc225d541cab61e13102ad4 |
README.md |
040000 |
tree |
- |
c3633971c8e36cc59dd5c41fd76fa9255765416e |
botly |
100644 |
blob |
172 |
3f148ab99d152565c46e51fd45e51030417f7faa |
example.py |
040000 |
tree |
- |
902cb30cdf6276223ffa4043fbdaee680d0a984c |
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