-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSendToSubscribers.py
executable file
·53 lines (43 loc) · 1.27 KB
/
SendToSubscribers.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
#!/usr/bin/python
# -*- coding: utf-8 -*-
import telegram
import sys
import ConfigParser
import sqlite3
from time import sleep
sys.stdout = open('log/sendMe.log', "w")
config = ConfigParser.ConfigParser()
config.read('settings.ini')
token = config.get('main', 'token')
mymessage = 'Spero di essere utile! Se ti va, lascia una recensione su di me... 5 stelle sarebbero ottime! ;) Clicca su questo link: https://telegram.me/storebot?start=unipdbot. Grazie!'
try:
text = sys.argv[1]
except:
text = mymessage
print 'sending message: ' + text
con = sqlite3.connect("db/logs.db")
cur = con.cursor()
cur.execute('SELECT * FROM log')
rows = cur.fetchall()
users = set([])
for row in rows:
users.add(str(row[6]))
bot = telegram.Bot(token)
for user in users:
<<<<<<< HEAD
try:
bot.sendMessage(chat_id=user,text=text)
print 'Message sent to: ' + user
sleep(0.4)
except telegram.error.TelegramError as e:
if 'unauthorized' in str(e).lower():
print 'unauthorized error with user: ' + user
=======
try:
bot.sendMessage(chat_id=user, text=text)
print 'Message sent to: ' + user
sleep(0.4)
except telegram.error.TelegramError as e:
if 'unauthorized' in str(e).lower():
print 'unauthorized error with user: ' + user
>>>>>>> develop