Passed
Push — master ( 9bfda5...dc2491 )
by Anas
02:12
created

modules.zalgo   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 5

2 Functions

Rating   Name   Duplication   Size   Complexity  
A zalgo_txt() 0 13 3
A module_init() 0 4 2
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