/botly/comm.py (069710f0ef84f1fbda9682a55191f87161743ee9) (1951 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):
        self.bot.print('Bot ready.')
        server = None
        for s in self.servers:
            server = s
        self.bot.set_bot_info(self.user, server)
        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_reaction_add(self, reaction, user):
        if user != self.user:
            await self.bot.react_to('on_reaction_add', reaction=reaction,
                user=user)

    async def on_reaction_remove(self, reaction, user):
        if user != self.user:
            await self.bot.react_to('on_reaction_remove', reaction=reaction,
                user=user)

    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 - 7fe31426b83442fe984fbceaebdfe52b5027603f botly
100644 blob 172 3f148ab99d152565c46e51fd45e51030417f7faa example.py
040000 tree - 397dee229020cc10f79921f6d7253dcd4a117273 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