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

modules.sticker_reply   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 6

2 Functions

Rating   Name   Duplication   Size   Complexity  
A module_init() 0 5 1
A sticker_rep() 0 10 5
1
#!/usr/bin/python
2
# -*- coding: utf-8 -*-
3
from telegram.ext import MessageHandler, Filters
4
from datetime import datetime
5
6
7
def module_init(gd):
8
    global keywords, sticker_path
9
    keywords = gd.config["keywords"]
10
    sticker_path = gd.config["sticker_path"]
11
    gd.dp.add_handler(MessageHandler(Filters.text, sticker_rep))
12
13
14
def sticker_rep(bot, update):
15
    current_time = datetime.strftime(datetime.now(), "%d.%m.%Y %H:%M:%S")
16
    if update.effective_message.chat.type == "channel":
17
        return
18
    for word in keywords:
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable keywords does not seem to be defined.
Loading history...
19
        if word in update.message.text:
20
            with open(sticker_path, "rb") as sticker:
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable sticker_path does not seem to be defined.
Loading history...
21
                update.message.reply_sticker(sticker)
22
            print(current_time, ">", "sticker", ">", update.message.from_user.username)
23
            break
24