Add broadcast method

This commit is contained in:
Klaus-Uwe Mitterer 2017-03-23 17:32:06 +01:00
parent 0c8b14c25d
commit 66ae28d589
2 changed files with 12 additions and 0 deletions

View file

@ -219,6 +219,7 @@ def timeline(bot, update, args = [10]):
db.commit()
# Streaming
mentionstreams = {}
def makeStream(bot, cid):
@ -264,3 +265,9 @@ def restart(bot, update):
else:
bottools.methods.unknown(bot, update)
def broadcast(bot, update, args):
if bottools.methods.isadmin(update.message):
for u in dbtools.dbHelper().allUsers():
bot.sendMessage(chat_id = u, text = ' '.join(args))
else:
bottools.methods.unknown(bot, update)

View file

@ -166,6 +166,11 @@ class dbObject:
for u in self.getAll():
yield u[0]
def allUsers(self):
self.executeQuery("SELECT cid FROM tokens;")
for u in self.getAll():
yield u[0]
def addFish(self, cid):
self.executeQuery("UPDATE tokens SET fish = fish + 1 WHERE cid = %i;" % int(cid))
self.commit()