REUTURS: Three random lines from the bee movie script
If a [replaceword] has been passed it will spit three random lines containing the word bee, but it replaced with [replaceword]
'''
lines = [] # The final list containing the lines
output = '' #The final output that the bot reuturns to the chat_id
args = msg['text'].replace(msg['text'].split(' ')[0],'')[1:] #What is after /beemovie or /beemovie@Jannie_Bot
if args.isspace() or args == '': #Is the command being queried like this /beemovie
lineno = randrange(0, (len(beescript)-2)) #what line number to use from beescript.txt
[lines.append(beescript[lineno+i]) for i in range(0,3)] #find a line and 2 after
output = "\n".join(lines)
else: #Is the command being queryied like this /beemovie [phrase]
while True: #repeat until bee is found in the lines
lines = []
lineno = randrange(0, (len(beescript)-2)) #what line number to use from beescript.txt
[lines.append(beescript[lineno+i]) for i in range(0,3)] #find a line and 2 after
if any('bee' in s for s in lines): #if there is bee in the lines
break #kill the loop
output = "\n".join(lines).replace('bee', args).replace('Bee', args).replace('TOMTOMTOMTOM','been') #replace words with the arg passed. TOMTOMTOMTOM is there because it kept replacing stuff in been
elif (("/ask" in msg['text']) and (len(msg['text']) > 4)) and ("/ask@Jannie_Bot" != msg['text'][:len("/ask@Jannie_Bot")]): #Is there actually a question or is it just /ask@Jannie_Bot
- elif (datetime.datetime.now() - RecentUsers[msg['from']['id']]) > datetime.timedelta(0, cooldown_sec): #Was the the timestamp in the dictionary more than cooldown_sec ago
- del RecentUsers[msg['from']['id']] #Remvoe the listing in the dict
- RecentUsers[msg['from']['id']] = datetime.datetime.now() #Put this message in the dictionary
+ elif (datetime.datetime.now() - recentUsers[msg['from']['id']]) > datetime.timedelta(0, cooldown_sec): #Was the the timestamp in the dictionary more than cooldown_sec ago
+ del recentUsers[msg['from']['id']] #Remvoe the listing in the dict
+ recentUsers[msg['from']['id']] = datetime.datetime.now() #Put this message in the dictionary
else: #Was the message sent less than cooldown_sec ago?
bot.sendMessage(chat_id, "Voetsek, don't edit your commands.", reply_to_message_id=msg['message_id'])
except:
if content_type == 'text':
if "hendrik" in (msg['text'].lower()):
bot.sendMessage(chat_id, 'THAT WITCH NAME IS NOT TO BE SPOKEN! DO NOT TRY EDIT YOUR WITCHCRAFT INTO YOUR MESSAGES IN AN ATTEMPT TO EVADE ME!', reply_to_message_id=msg['message_id'])