def results(self, message, text):
        self.bot.send_chat_action(message.chat.id, ChatAction.TEXT)
        if not text:
            m = self.bot.send_message(
                message.chat.id,
                'For which date?\nPlease use the format `YEAR-MM-DD`',
                reply_to_message_id=message.message_id,
                reply_markup=ForceReply.create(selective=True),
                parse_mode='Markdown'
            ).wait()
            if isinstance(m, Error):
                print 'ERROR:', m
            else:
                self.need_reply(self.results, message, out_message=m, selective=True)
            return

        try:
            return self.bot.return_message(
                message.chat.id,
                self._results(text),
                parse_mode='Markdown'
            )
        except:
            m = self.bot.send_message(
                message.chat.id,
                'Please *use* the format `YEAR-MM-DD`',
                reply_to_message_id=message.message_id,
                reply_markup=ForceReply.create(selective=True),
                parse_mode='Markdown'
            ).wait()
            if isinstance(m, Error):
                print 'ERROR:', m
            else:
                self.need_reply(self.results, message, out_message=m, selective=True)
Exemple #2
0
    def buttgmt(self, message, text):
        self.bot.send_chat_action(message.chat.id, ChatAction.TEXT)
        if not text:
            m = self.bot.send_message(
                message.chat.id,
                '''\
What's your GMT offset?
Example, if you are in Beijing (China), the timezone is GMT+8, so you answer:
*8*
If you are in Boston (USA), it is GMT-5, so you answer:
*-5*
Apologies to India, Iran and some other places, but offsets are integers at the moment, so half-hour deviations are not supported...''',
                reply_to_message_id=message.message_id,
                reply_markup=ForceReply.create(selective=True),
                parse_mode='Markdown'
            ).wait()
            self.need_reply(self.buttgmt, message, out_message=m, selective=True)
            return

        try:
            offset = int(text)
        except:
            offset = -999

        if offset < -12 or offset > 12:
            res = 'Invalid offset value. It should be a number between -12 and 12 (no half-hour offsets at the moment, apologies to India, Iran, etc)'
        else:
            res = 'Timezone set to GMT'
            if offset >= 0:
                res += '+'
            res += str(offset)
            self.save_data(message.chat.id, key2='timezone', obj=offset)

        return self.bot.return_message(message.chat.id, res, parse_mode='Markdown')
Exemple #3
0
    def results(self, message, text):
        self.bot.send_chat_action(message.chat.id, ChatAction.TEXT)
        if not text:
            m = self.bot.send_message(
                message.chat.id,
                'For which date?\nPlease use the format `YEAR-MM-DD`',
                reply_to_message_id=message.message_id,
                reply_markup=ForceReply.create(selective=True),
                parse_mode='Markdown').wait()
            if isinstance(m, Error):
                print 'ERROR:', m
            else:
                self.need_reply(self.results,
                                message,
                                out_message=m,
                                selective=True)
            return

        try:
            return self.bot.return_message(message.chat.id,
                                           self._results(text),
                                           parse_mode='Markdown')
        except:
            m = self.bot.send_message(
                message.chat.id,
                'Please *use* the format `YEAR-MM-DD`',
                reply_to_message_id=message.message_id,
                reply_markup=ForceReply.create(selective=True),
                parse_mode='Markdown').wait()
            if isinstance(m, Error):
                print 'ERROR:', m
            else:
                self.need_reply(self.results,
                                message,
                                out_message=m,
                                selective=True)
Exemple #4
0
    def buttgmt(self, message, text):
        self.bot.send_chat_action(message.chat.id, ChatAction.TEXT)
        if not text:
            m = self.bot.send_message(
                message.chat.id,
                '''\
What's your GMT offset?
Example, if you are in Beijing (China), the timezone is GMT+8, so you answer:
*8*
If you are in Boston (USA), it is GMT-5, so you answer:
*-5*
Apologies to India, Iran and some other places, but offsets are integers at the moment, so half-hour deviations are not supported...''',
                reply_to_message_id=message.message_id,
                reply_markup=ForceReply.create(selective=True),
                parse_mode='Markdown').wait()
            self.need_reply(self.buttgmt,
                            message,
                            out_message=m,
                            selective=True)
            return

        try:
            offset = int(text)
        except:
            offset = -999

        if offset < -12 or offset > 12:
            res = 'Invalid offset value. It should be a number between -12 and 12 (no half-hour offsets at the moment, apologies to India, Iran, etc)'
        else:
            res = 'Timezone set to GMT'
            if offset >= 0:
                res += '+'
            res += str(offset)
            self.save_data(message.chat.id, key2='timezone', obj=offset)

        return self.bot.return_message(message.chat.id,
                                       res,
                                       parse_mode='Markdown')