-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
43 lines (36 loc) · 1.31 KB
/
main.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
35
36
37
38
39
40
41
42
43
import configparser
from GLC import GLC
import telebot
from telebot import types
bot = telebot.TeleBot("", parse_mode="MARKDOWN")
mm = types.ReplyKeyboardMarkup(row_width=2)
button1 = types.KeyboardButton("Поиск")
mm.add(button1)
markup = types.InlineKeyboardMarkup()
btn = types.InlineKeyboardButton(text='Отслеживать', callback_data="yes")
markup.add(btn)
config = configparser.ConfigParser()
config.read('s.ini')
glc = GLC(config['main']['cookie'], config['main']['url'])
@bot.callback_query_handler(func=lambda call: True)
def callback_query(call):
f = open("users", "a+", encoding='utf-8')
f.write(call.message.text + "\n")
f.close()
@bot.message_handler(func=lambda m: True)
def mess(message):
ulist = glc.get_user_list()
if message.text == "/start":
for user in ulist:
bot.send_message(message.chat.id, user, reply_markup=markup)
else:
f = open("users", encoding='utf-8').readlines()
ulist = ""
for user in f:
if glc.get_user_loc(user) == config['main']['adr']:
ulist += user
else:
bot.send_message(message.chat.id, "Никого нет", reply_markup=markup)
if ulist != "":
bot.send_message(message.chat.id, ulist, reply_markup=markup)
bot.infinity_polling()