-
Notifications
You must be signed in to change notification settings - Fork 2
/
pesatbot.py
34 lines (25 loc) · 1.13 KB
/
pesatbot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# -*- coding: utf-8 -*-
import random
import telebot
import os
import unicodedata
# Creating the bot
TOKEN = os.environ['TELEGRAM_BOT_TOKEN'] # Token previously stored in an environment var
bot = telebot.TeleBot(TOKEN)
def select_response(message):
responses = ['Ie {} tio, no et canses?', '{}, eres un puto pesat de tio', 'Ie {}, ja hi ha prou que ja cansa',
'Collons {}, que pesat eres quan vols', "Que si {}, tio pesat, que ja t'hem llegit"]
response_to_use = random.choice(responses)
name = unicodedata.normalize('NFKD', message.from_user.first_name).encode('ascii','ignore')
response = response_to_use.format(name)
return response
# The decorator (@bot.message_handler) indicates the type of messages that will activate this function
# In this case, we'll activate it for every message. See telebot API for more possibilities
@bot.message_handler(func=lambda message: True)
def pole_reply(message):
# If the message contains the word 'pole' (case insensitive), the bot replies
if 'pole' in message.text.lower():
resposta = select_response(message)
bot.reply_to(message, resposta)
bot.delete_webhook()
bot.polling(none_stop=True)