-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot_2.py
More file actions
144 lines (141 loc) · 7.22 KB
/
bot_2.py
File metadata and controls
144 lines (141 loc) · 7.22 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# -*- coding: utf-8 -*-
import vk
from requests import post
from logic import get_date, save_matching, ping
from const import vk_keyboard, tg_token, vk_token, wb_id, nasa_id, group_id
import json
import telebot
from time import sleep
from text import greeting, return_date, get_ip, no_ip, operator
from text import sber_0, sber_1, sber_2, sber_3, sber_4
from datetime import datetime
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
users = []
bot = telebot.TeleBot(tg_token)
session = vk.Session(access_token=vk_token)
api = vk.API(session, v='5.85')
longPoll = api.groups.getLongPollServer(group_id=group_id)
server, key, ts = longPoll['server'], longPoll['key'], longPoll['ts']
url = "https://api.telegram.org/bot{}/".format(tg_token)
while True:
longPoll = post('%s' % server, data={'act': 'a_check',
'key': key,
'ts': ts,
'wait': 90}).json()
if len(longPoll['updates']) != 0:
time = str(datetime.now())[:16]
for update in longPoll['updates']:
if update['type'] == 'message_new':
api.messages.markAsRead(peer_id=update['object']['user_id'])
text = update['object']['body']
user = api.users.get(user_ids=update['object']['user_id'])
name = user[0]['first_name']
last_name = user[0]['last_name']
tg_text = '👀 ' + time + ' \n ' + '👃 ' + name \
+ ' ' + last_name + ' \n ' + '👅 ' + text
post(url + "sendMessage", data={'chat_id': wb_id,
'text': tg_text})
if text == 'Начать' or text == '⏳ обновить клавиатуру 💡':
api.messages.send(peer_id=update['object']['user_id'],
message=greeting,
keyboard=vk_keyboard)
elif text == '📅 Дата окончания оплаты':
id = str(update['object']['user_id'])
with open('IP.json', 'r+') as IP:
data = json.load(IP)
if id in data:
date = get_date(data[id])
message = return_date + date
api.messages.send(
peer_id=update['object']['user_id'],
message=message)
else:
users.append(update['object']['user_id'])
api.messages.send(
peer_id=update['object']['user_id'],
message=get_ip)
elif '10.10.' in text or update['object']['user_id'] in users:
users.remove(update['object']['user_id'])
ip = text
date = get_date(ip)
if date != '':
id = update['object']['user_id']
message = return_date + date
save_matching(id, ip)
api.messages.send(
peer_id=update['object']['user_id'],
message=message)
api.messages.send(
peer_id=update['object']['user_id'],
message='IP сохранен. Больше писать его не нужно😊')
else:
api.messages.send(peer_id=update['object']['user_id'],
message=no_ip)
api.messages.send(peer_id=update['object']['user_id'],
attachment='doc-129298566_483539786')
elif text == '💳 Сбербанк ОнЛ@йн':
api.messages.send(
peer_id=update['object']['user_id'],
message=sber_0)
sleep(2)
api.messages.send(
peer_id=update['object']['user_id'],
message=sber_1,
attachment='photo-129298566_456239068')
sleep(5)
api.messages.send(
peer_id=update['object']['user_id'],
message=sber_2,
attachment='photo-129298566_456239070')
sleep(5)
api.messages.send(
peer_id=update['object']['user_id'],
message=sber_3,
attachment='photo-129298566_456239071')
sleep(5)
api.messages.send(
peer_id=update['object']['user_id'],
message=sber_4,
attachment='photo-129298566_456239074')
elif text == '🏄🌏 Есть Интернет?':
sleep(1)
api.messages.send(peer_id=update['object']['user_id'],
message='Запускаем квантово🔨карпаскуляр'
'ный тест соединения')
sleep(1)
api.messages.send(
peer_id=update['object']['user_id'],
message='💨')
sleep(1)
api.messages.send(
peer_id=update['object']['user_id'],
message='💨💨💨')
sleep(1)
api.messages.send(
peer_id=update['object']['user_id'],
message='💨💨💨💨💨')
sleep(1)
if ping('194.105.212.27'):
api.messages.send(
peer_id=update['object']['user_id'],
message='✨Проблем со связью не обнаружено 👌.'
' Приятного дня!✨')
api.messages.send(peer_id=update['object']['user_id'],
attachment='doc-129298566_483539744')
else:
sleep(3)
api.messages.send(
peer_id=update['object']['user_id'],
message='В данным момент имеются проблемы 🚧 со'
' связью. Приносим извинения😔.')
elif update['object']['user_id'] not in users:
tg_text = '👀 ' + time + ' \n ' + '👃 ' + name \
+ ' ' + last_name + ' \n ' + '👅 ' + text
post(url + "sendMessage", data={'chat_id': nasa_id,
'text': tg_text})
api.messages.send(
peer_id=update['object']['user_id'],
message=operator)
ts = longPoll['ts']