-
Notifications
You must be signed in to change notification settings - Fork 2
/
icodrops.py
executable file
·58 lines (45 loc) · 1.47 KB
/
icodrops.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/python3
from telethon import TelegramClient
from telethon import utils
import time
import os, sys
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, from telegram bot")
application = tornado.web.Application([
(r"/", MainHandler),
])
#My API values
api_id = 181055
api_hash ='8c267b7f0bcbdc604fe27b12142a9687'
phone_number = '+37368351333'
client = TelegramClient('me', api_id, api_hash)
client.start()
#print(client.get_me().stringify())
#client.send_message('self', 'Hello World from Telethon!')
#dialogs, entities = client.get_dialogs(dialog_count)
for message in client.get_message_history('icodrops', limit=1):
last = message.id
print(message.id)
# print(message.media)
# print(message.media.caption)
while True:
for message in client.get_message_history('icodrops', min_id=last):
# print(utils.get_display_name(message.sender), message.id, message.message)
cryptomessage = message.message
if message.id > last:
last = message.id
# print(last)
if cryptomessage != '':
mesg1 = cryptomessage.encode('utf-8')
# print(mesg1)
client.send_message('cryptoanalizatorfeed', mesg1)
time.sleep(1)
else:
print(message.media.caption)
time.sleep(30)
if __name__ == "__main__":
application.listen(8081)
tornado.ioloop.IOLoop.instance().start()