示例#1
0
 def __init__(self, bot, config):
     initiator = TelegramDBInit(bot.database)
     self.bot = bot
     self.tbot = None
     self.pokemons = config.get('alert_catch', {})
     self.whoami = "TelegramHandler"
     self.config = config
     self.chat_handler = ChatHandler(self.bot, self.pokemons)
     self._connect()
示例#2
0
 def __init__(self, bot, config):
     self.bot = bot
     self.dbot = None
     self.master = config.get('master', None)
     if self.master == None:
         return
     self.pokemons = config.get('alert_catch', {})
     self.whoami = "DiscordHandler"
     self.config = config
     self.chat_handler = ChatHandler(self.bot, [])
示例#3
0
    def __init__(self, bot, pokemons, config):
        self.bot = bot
        request.CON_POOL_SIZE = 16
        self.config = config
        self.chat_handler = ChatHandler(self.bot, pokemons)
        self.master = self.config.get('master')

        with self.bot.database as conn:
            # initialize the DB table if it does not exist yet
            initiator = TelegramDBInit(bot.database)
            if unicode(self.master).isnumeric():  # master is numeric
                self.bot.logger.info(
                    "Telegram master is valid (numeric): {}".format(
                        self.master))
            elif self.master is not None:  # Master is not numeric, fetch from db
                self.bot.logger.info(
                    "Telegram master is not numeric: {}".format(self.master))
                c = conn.cursor()
                srchmaster = re.sub(r'^@', '', self.master)
                c.execute(
                    "SELECT uid from telegram_uids where username = '******'".
                    format(srchmaster))
                results = c.fetchall()
                if len(
                        results
                ) > 0:  # woohoo, we already saw a message from this master and therefore have a uid
                    self.bot.logger.info(
                        "Telegram master UID from datastore: {}".format(
                            results[0][0]))
                    self.master = results[0][0]
                else:  # uid not known yet
                    self.bot.logger.info(
                        "Telegram master UID not in datastore yet")

        self.pokemons = pokemons
        self._tbot = None
        self.config = config
        self.master = None
示例#4
0
文件: server.py 项目: ddrc1/Redes-2
from chat_handler import ChatHandler

if __name__ == "__main__":
    chatHandler = ChatHandler('localhost', 4006)
    chatHandler.start()
示例#5
0
 def conversations_main(conversations):
     res_list = []
     for conversation in conversations:
         app = ChatHandler().main(conversation)
         res_list.append((conversation.title, app))
     return res_list