Example #1
0
def handler(update):
    message = update.message
    text = message_utils.get_text_or_caption(message)
    if not text:
        return
    params = filters.command(text, 'rand')

    if params is not None:
        result = None
        if params == []:
            result = random.randint(1, 9)

        elif params[0] == 'help':
            result = help_text

        elif len(params) == 1:
            try:
                result = random.randint(1, int(params[0]))
            except ValueError:
                result = value_error_text

        elif len(params) == 2:
            try:
                result = random.randint(int(params[0]), int(params[1]))
            except ValueError:
                result = value_error_text

        if result:
            send_message(message.chat.id, result, parse_mode='Markdown')
            return True
Example #2
0
def handler(update):
    message = update.message
    text = message_utils.get_text_or_caption(message)
    if not text:
        return
    params = filters.command(text, 'help')

    if params is not None:
        send_message(message.chat.id, help_text, parse_mode='Markdown')
        return True
Example #3
0
def handler(update):
    message = update.message
    text = message_utils.get_text_or_caption(message)
    if not text:
        return
    params = filters.command(text, 'info')

    if params is not None:
        if not params == [] and params[0] == 'help':
            result = help_text
        else:
            result = '```' + json.dumps(message.json, indent=2) + '```'

        send_message(message.chat.id, result, parse_mode='Markdown')
        return True
Example #4
0
def handler(update):
    message = update.message
    text = message_utils.get_text_or_caption(message)
    if not text:
        return
    params = filters.command(text, 'send')

    if params is not None:
        result = ''
        to = message.chat.id

        if params == [] or params[0] == 'help':
            result = help_text

        else:
            for param in params:
                if param.startswith('to='):
                    to = param.split('=')[1]
                else:
                    result += param + ' '

        if result:
            send_message(to, result.encode('utf-8'))
            return True
Example #5
0
def debug(text):
    send_message(ADMIN_ID, text, parse_mode='Markdown')