Completed
Push — master ( 8d1b1d...5954bd )
by Anas
46s
created

zalgo_txt()   A

Complexity

Conditions 3

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
c 0
b 0
f 0
dl 0
loc 13
rs 9.4285
1
#!/usr/bin/python
2
# -*- coding: utf-8 -*-
3
from modules.logging import log_command
4
from telegram.ext import CommandHandler
5
from datetime import datetime
6
from zalgo_text import zalgo    
7
8
9
def module_init(gd):
10
    commands = gd.config["commands"]
11
    for command in commands:
12
        gd.dp.add_handler(CommandHandler(command, zalgo_txt, pass_args=True))
13
14
15
def zalgo_txt(bot, update, args):
16
    current_time = datetime.strftime(datetime.now(), "%d.%m.%Y %H:%M:%S")
17
    if update.message.reply_to_message is not None:
18
        args = update.message.reply_to_message.text
19
        args = args.split(" ")
20
    input_text = " ".join(args).lower()
21
    if input_text == "":
22
        update.message.reply_text("Type in some text!")
23
        return
24
    zalgofied_text = zalgo.zalgo().zalgofy(input_text)
25
    update.message.reply_text(zalgofied_text)
26
    print(current_time, ">", "/zalgo", ">", update.message.from_user.username)
27
    log_command(bot, update, current_time, "zalgo")
28