Esempio n. 1
0
 def handle_character(self, msg, chat_handler):
     if (yield from assert_text(msg,chat_handler)):
         char_name = msg["text"]
         if len(Character.select().where(Character.name == char_name)) > 0:
             location = Character.select().where(Character.name == char_name).get().location
             self.finished()
             yield from chat_handler.sender.sendMessage(_s["msg_charin"]+location)
         else:
             yield from chat_handler.sender.sendMessage(_s["msg_cantfindchar"])
Esempio n. 2
0
 def handle_character(self, msg, chat_handler):
     if (yield from assert_text(msg,chat_handler)):
         char_name = msg["text"]
         if len(Character.select().where(Character.name == char_name)) > 0:
             self._target_user = Character.select().where(Character.name == char_name).get().user
             self.current_handler = self.handle_message
             yield from chat_handler.sender.sendMessage(_s["msg_forwardmessageq"])
         else:
             yield from chat_handler.sender.sendMessage(_s["msg_cantfindchar"])
Esempio n. 3
0
 async def handle_character(self, msg, chat_handler):
     if await assert_text(msg, chat_handler):
         self.char_name = msg["text"]
         if len(Character.select().where(Character.name == self.char_name)) > 0:
             user = Character.select().where(Character.name == self.char_name).get().user
             self.characters = [char for char in Character.select().where(Character.user == user)]
             self.finished()
             await self.send_template(chat_handler, "ALTSOF")
         else:
             await self.send_template(chat_handler, "CANT_FIND_CHARACTER")
Esempio n. 4
0
 async def handle_character(self, msg, chat_handler):
     if await assert_text(msg, chat_handler):
         char_name = msg["text"]
         if len(Character.select().where(Character.name == char_name)) > 0:
             user = Character.select().where(Character.name == char_name).get().user
             user.auth_level = -1
             user.save()
             self.finished()
             await chat_handler.sender.sendMessage(_s["msg_userbanned"])
         else:
             await chat_handler.sender.sendMessage(_s["msg_cantfindchar"])
Esempio n. 5
0
 def handle_character(self, msg, chat_handler):
     if (yield from assert_text(msg,chat_handler)):
         char_name = msg["text"]
         if len(Character.select().where(Character.name == char_name)) > 0:
             user = Character.select().where(Character.name == char_name).get().user
             user.auth_level = max(user.auth_level, 3)
             user.save()
             self.finished()
             yield from chat_handler.sender.sendMessage(_s["msg_userelevated"])
         else:
             yield from chat_handler.sender.sendMessage(_s["msg_cantfindchar"])
Esempio n. 6
0
 async def handle_character(self, msg, chat_handler):
     if await assert_text(msg, chat_handler):
         char_name = msg["text"]
         if len(Character.select().where(Character.name == char_name)) > 0:
             user = Character.select().where(
                 Character.name == char_name).get().user
             user.auth_level = -1
             user.save()
             self.finished()
             await chat_handler.sender.sendMessage(_s["msg_userbanned"])
         else:
             await chat_handler.sender.sendMessage(_s["msg_cantfindchar"])
Esempio n. 7
0
 def handle_character(self, msg, chat_handler):
     if (yield from assert_text(msg, chat_handler)):
         char_name = msg["text"]
         if len(Character.select().where(Character.name == char_name)) > 0:
             self._target_user = Character.select().where(
                 Character.name == char_name).get().user
             self.current_handler = self.handle_message
             yield from chat_handler.sender.sendMessage(
                 _s["msg_forwardmessageq"])
         else:
             yield from chat_handler.sender.sendMessage(
                 _s["msg_cantfindchar"])
Esempio n. 8
0
 def handle_character(self, msg, chat_handler):
     if (yield from assert_text(msg, chat_handler)):
         char_name = msg["text"]
         if len(Character.select().where(Character.name == char_name)) > 0:
             location = Character.select().where(
                 Character.name == char_name).get().location
             self.finished()
             yield from chat_handler.sender.sendMessage(_s["msg_charin"] +
                                                        location)
         else:
             yield from chat_handler.sender.sendMessage(
                 _s["msg_cantfindchar"])
Esempio n. 9
0
    def initial_handler(self, msg, chat_handler):
        if len(Character.select().where(Character.user == chat_handler.user)) > 0:
            chars = "Currently I know of the following characters:\n"
            options = []
            for char in Character.select().where(Character.user == chat_handler.user):
                chars += "  " + char.name + "\n"
                options.append(char.name)

            self.finished()
            yield from chat_handler.sender.sendMessage(chars)
        else:
            self.finished()
            yield from chat_handler.sender.sendMessage(_s["msg_nochars"])
Esempio n. 10
0
 def handle_character(self, msg, chat_handler):
     if (yield from assert_text(msg, chat_handler)):
         character_name = msg["text"]
         if len(Character.select().where(Character.user == chat_handler.user,
                                         Character.name == character_name)) > 0:
             char = Character.select().where(Character.user == chat_handler.user,
                                             Character.name == character_name).get()
             chat_handler.user.main_character = char
             chat_handler.user.save()
             self.finished()
             yield from chat_handler.sender.sendMessage(_s["msg_maincharset"]+char.name,
                                                        reply_markup={'hide_keyboard': True})
         else:
             yield from chat_handler.sender.sendMessage(_s["msg_notyourchar"])
Esempio n. 11
0
    def initial_handler(self, msg, chat_handler):
        if len(Character.select().where(
                Character.user == chat_handler.user)) > 0:
            chars = "Currently I know of the following characters:\n"
            options = []
            for char in Character.select().where(
                    Character.user == chat_handler.user):
                chars += "  " + char.name + "\n"
                options.append(char.name)

            self.finished()
            yield from chat_handler.sender.sendMessage(chars)
        else:
            self.finished()
            yield from chat_handler.sender.sendMessage(_s["msg_nochars"])
Esempio n. 12
0
    def initial_handler(self, msg, chat_handler):
        if len(Character.select().where(Character.user == chat_handler.user)) > 0:
            chars = "Please respond with the name of your main character\n\n"
            chars += "Currently I know of the following characters:\n"
            options = []
            for char in Character.select().where(Character.user == chat_handler.user):
                chars += "  " + char.name + "\n"
                options.append(char.name)

            show_keyboard = {'keyboard': [options]}

            self.current_handler = self.handle_character
            yield from chat_handler.sender.sendMessage(chars, reply_markup=show_keyboard)
        else:
            self.finished()
            yield from chat_handler.sender.sendMessage(_s["msg_nochars"])
Esempio n. 13
0
async def legacy_pingplayer(request):
    player = request.match_info.get('player', "player")
    text = request.match_info.get('text', "'message'")

    # look up the player in api keys,  find who registered it,  get their id,  then send the 'message'
    await bot.sendMessage(Character.select().where(Character.name == player).get().user.telegram_id, text)

    return web.Response(body="{}".encode('utf-8'))
Esempio n. 14
0
async def legacy_pingplayer(request):
    player = request.match_info.get('player', "player")
    text = request.match_info.get('text', "'message'")

    # look up the player in api keys,  find who registered it,  get their id,  then send the 'message'
    await bot.sendMessage(
        Character.select().where(
            Character.name == player).get().user.telegram_id, text)

    return web.Response(body="{}".encode('utf-8'))
Esempio n. 15
0
    def handle_group(self, msg, chat_handler):
        if (yield from assert_text(msg,chat_handler)):
            group_name = msg["text"]

            if len(Group.select().where(Group.group_name==group_name)) > 0:
                corps = [c.corporation_name for c in Character.select()]
                corp_count = [t[0] for t in Counter(corps).most_common(10)]
                options = [corp_count[:5], corp_count[5:]]

                self._group = Group.select().where(Group.group_name==group_name).get()

                self.current_handler = self.handle_corp
                yield from chat_handler.sender.sendMessage(_s["msg_whichingamecorp"],reply_markup={'keyboard': options})
            else:
                yield from chat_handler.sender.sendMessage(_s["msg_notagroup"])
Esempio n. 16
0
    def handle_group(self, msg, chat_handler):
        if (yield from assert_text(msg,chat_handler)):
            group_name = msg["text"]

            if len(Group.select().where(Group.group_name==group_name)) > 0:
                shiptypes = [c.shiptype_name for c in Character.select()]
                shiptypes_count = [t[0] for t in Counter(shiptypes).most_common(10) if t[0] != ""]
                options = [shiptypes_count[:5], shiptypes_count[5:]]

                self._group = Group.select().where(Group.group_name == group_name).get()

                self.current_handler = self.handle_shiptype
                yield from chat_handler.sender.sendMessage(_s["msg_whichingameship"],reply_markup={'keyboard': options})
            else:
                yield from chat_handler.sender.sendMessage(_s["msg_notagroup"])
Esempio n. 17
0
    def handle_group(self, msg, chat_handler):
        if (yield from assert_text(msg, chat_handler)):
            group_name = msg["text"]

            if len(Group.select().where(Group.group_name == group_name)) > 0:
                corps = [c.corporation_name for c in Character.select()]
                corp_count = [t[0] for t in Counter(corps).most_common(10)]
                options = [corp_count[:5], corp_count[5:]]

                self._group = Group.select().where(
                    Group.group_name == group_name).get()

                self.current_handler = self.handle_corp
                yield from chat_handler.sender.sendMessage(
                    _s["msg_whichingamecorp"],
                    reply_markup={'keyboard': options})
            else:
                yield from chat_handler.sender.sendMessage(_s["msg_notagroup"])
Esempio n. 18
0
    def handle_group(self, msg, chat_handler):
        if (yield from assert_text(msg, chat_handler)):
            group_name = msg["text"]

            if len(Group.select().where(Group.group_name == group_name)) > 0:
                alliances = [c.alliance_name for c in Character.select()]
                alliances_count = [
                    t[0] for t in Counter(alliances).most_common(10)
                    if t[0] != ""
                ]
                options = [alliances_count[:5], alliances_count[5:]]

                self._group = Group.select().where(
                    Group.group_name == group_name).get()

                self.current_handler = self.handle_alliance
                yield from chat_handler.sender.sendMessage(
                    _s["msg_whichingamealliance"],
                    reply_markup={'keyboard': options})
            else:
                yield from chat_handler.sender.sendMessage(_s["msg_notagroup"])