Make outgoing tweet notifications optional
This commit is contained in:
parent
97bfea2f24
commit
3537379e99
|
@ -83,6 +83,12 @@ def toggleTweet(bot, update):
|
|||
except tweepy.error.TweepError as e:
|
||||
bottools.methods.twoExceptions(e, update.message)
|
||||
|
||||
def toggleConfirmations(bot, update):
|
||||
try:
|
||||
update.message.reply_text(bottools.strings.toggleConfirmations % (bottools.strings.toggleTweetOn if dbtools.dbHelper().toggleConfirmations(update.message.chat_id) else bottools.strings.toggleTweetOff))
|
||||
except tweepy.error.TweepError as e:
|
||||
bottools.methods.twoExceptions(e, update.message)
|
||||
|
||||
def unknown(bot, update):
|
||||
update.message.reply_text(bottools.strings.unknownCommand)
|
||||
|
||||
|
@ -184,7 +190,8 @@ def explicitTweet(bot, update, args, reply = None):
|
|||
else:
|
||||
status = two.tweet(' '.join(args), reply)
|
||||
|
||||
bottools.methods.tweetMessage(status, update.message.chat_id, bot)
|
||||
if dbtools.dbHelper().getCStatus(update.message.chat_id):
|
||||
bottools.methods.tweetMessage(status, update.message.chat_id, bot)
|
||||
|
||||
except tweepy.error.TweepError as e:
|
||||
bottools.methods.twoExceptions(e, update.message)
|
||||
|
@ -484,7 +491,9 @@ commands = {
|
|||
"thread": thread,
|
||||
"timeline": timeline,
|
||||
"togglebroadcasts": togglebroadcasts,
|
||||
"toggleconfirmations": toggleConfirmations,
|
||||
"togglementions": mentionstream,
|
||||
"toggletweet": toggleTweet,
|
||||
"tweet": explicitTweet,
|
||||
"unauth": unauth,
|
||||
"unfollow": unfollow,
|
||||
|
|
|
@ -36,6 +36,7 @@ Additionally, you will be able to use the following commands:
|
|||
* /quote TWEET - Quote a tweet. You will need to pass a tweet ID (TWEET) as returned by /timeline.
|
||||
* /reply TWEET TEXT - Reply TEXT to a tweet. You will need to pass a tweet ID (TWEET) as returned by /timeline. If you do not include any mentions, I will take care of this for you.
|
||||
* /retweet TWEET - Retweet a tweet. You will need to pass a tweet ID (TWEET) as returned by /timeline.
|
||||
* /toggleconfirmations - Turn on/off notifications about tweets you posted yourself.
|
||||
* /togglementions - Turn on/off notifications when you are mentioned in a tweet.
|
||||
* /toggletweet - Turn automatic tweeting of messages on/off. Useful in groups.
|
||||
* /tweet TEXT - Explicitly tweet TEXT even if automatic tweeting is off (/toggletweet).
|
||||
|
@ -55,6 +56,9 @@ Have fun!'''
|
|||
toggleBroadcasts = '''Broadcast notifications are now %s.'''
|
||||
|
||||
|
||||
toggleConfirmations = '''Confirmations for outgoing tweets are now %s.'''
|
||||
|
||||
|
||||
toggleTweet = '''Automatic tweeting is now %s.'''
|
||||
|
||||
|
||||
|
|
|
@ -144,6 +144,19 @@ class dbObject:
|
|||
|
||||
return self.getBStatus(cid)
|
||||
|
||||
def getCStatus(self, cid):
|
||||
try:
|
||||
self.executeQuery("SELECT confirmations FROM tokens WHERE cid = %i;" % int(cid))
|
||||
return True if int(self.cur.fetchone()[0]) == 1 else False
|
||||
except:
|
||||
raise ValueError("No such user: %i" % int(cid))
|
||||
|
||||
def toggleConfirmations(self, cid):
|
||||
self.executeQuery("UPDATE tokens SET confirmations = NOT confirmations WHERE cid = %i;" % int(cid))
|
||||
self.commit()
|
||||
|
||||
return self.getCStatus(cid)
|
||||
|
||||
def getTStatus(self, cid):
|
||||
try:
|
||||
self.executeQuery("SELECT tweet FROM tokens WHERE cid = %i;" % int(cid))
|
||||
|
|
2
setup.py
2
setup.py
|
@ -65,7 +65,7 @@ if not db.isInitialized():
|
|||
db.executeQuery("CREATE TABLE names(`id` TEXT NOT NULL, `name` TEXT NOT NULL, `since` INTEGER NOT NULL, `until` INTEGER, PRIMARY KEY(id, until));")
|
||||
db.executeQuery("CREATE TABLE retweets(id INT PRIMARY KEY, author VARCHAR(30), created_at VARCHAR(30), text TEXT);")
|
||||
db.executeQuery("CREATE TABLE lyrics(id INTEGER PRIMARY KEY AUTOINCREMENT, text VARCHAR(140) NOT NULL, ref INT NOT NULL default '0', tweet_id INT, active BOOLEAN default '0');")
|
||||
db.executeQuery("CREATE TABLE tokens(`cid` INT PRIMARY KEY, `ato` TEXT, `ase` TEXT, `tweet` BOOLEAN DEFAULT 1, `fish` INT DEFAULT 0, `mentions` BOOLEAN DEFAULT 0, `broadcast` BOOLEAN DEFAULT 1);")
|
||||
db.executeQuery("CREATE TABLE tokens(`cid` INT PRIMARY KEY, `ato` TEXT, `ase` TEXT, `tweet` BOOLEAN DEFAULT 1, `fish` INT DEFAULT 0, `mentions` BOOLEAN DEFAULT 0, `broadcast` BOOLEAN DEFAULT 1, `confirmations` BOOLEAN DEFAULT 1);")
|
||||
db.executeQuery("CREATE TABLE timelines(`cid` INT, `nr` INT, `tid` INT, PRIMARY KEY(cid, nr));")
|
||||
db.commit()
|
||||
|
||||
|
|
Loading…
Reference in a new issue