def c**t(bot, update): if not isNewCommand(update): return if checkAccess(update): message = [1] if len(update.message.text.split(" ", 1)) > 1: message = update.message.text.split(" ", 1)[1].strip() else: message = randomCunt() send(bot, message.encode('utf-8')) count = 5 while count: send(bot, "{}".format(count)) time.sleep(1) count -= 1 send(bot, "PLAY!") # also call /new config = loadConfig() if config['lastRoll'] is not None: newAlbumSetPosition(bot, config['lastRoll']) config['lastRoll'] = None saveConfig(config)
def c**t(bot, update): if not isNewCommand(update): return if not checkAccess(update): return message = [1] if len(update.message.text.split(" ", 1)) > 1: message = update.message.text.split(" ", 1)[1].strip() else: message = randomCunt() send(bot, message) count = 5 while count: send(bot, "{}".format(count)) time.sleep(1) count -= 1 send(bot, "PLAY!") config = loadConfig() if config['isPlaying'] == True: return # also call /new if config['lastRoll'] is not None: newAlbumSetPosition(bot, config['lastRoll']) # newAlbumSetPosition updates config, need to reload it from disk config = loadConfig() config['lastRoll'] = None saveConfig(config)
def removeRoll(bot, update): if not isNewCommand(update): return if update.message.from_user.username == "ysoftware": config = loadConfig() config['lastRoll'] = None saveConfig(config)
def endSession(): config = loadConfig() config.pop('artist', None) config.pop('track', None) config.pop('album', None) config.pop('suggested', None) config.pop('year', None) config['isPlaying'] = False saveConfig(config)
def dontTagMe(bot, update): id = update.effective_user.id config = loadConfig() if 'tagList' not in config and id not in config['tagList']: config['tagList'] = [] bot.sendMessage(id, "You are not subscribed to /tag updates.") else: config['tagList'].remove(id) bot.sendMessage(id, "You are now unsubscribed from /tag updates.") saveConfig(config)
def nextSong(bot, update): if not isNewCommand(update): return if not checkAccess(update): return config = loadConfig() if config['isPlaying'] == True: trackName = update.message.text.split(" ", 1)[1].strip() if len(trackName) > 0 and len( config['artist']) > 0 and trackName != config['track']: config['track'] = trackName text = "#musictheatre {0} - {1}".format(config['artist'], config['track']) send(bot, text) saveConfig(config) else: send(bot, "What album was that again?")
def roll(bot, update): if not isNewCommand(update): return if not checkAccess(update): return config = loadConfig() if config['isPlaying'] == False: wks = auth() suggestionNames = filter(fNonEmpty, map(fValue, wks.range('B4:B100'))) illegalNames = map(fLower, filter(fNonEmpty, map(fValue, wks.range('G4:G9')))) suggestionsCount = len(suggestionNames) if suggestionsCount > 0: for _ in range(5): # get random (favor older suggestions) result = getRandom(suggestionsCount - 1) spreadsheetNumber = result + 4 rolled = map( fValue, wks.range('A' + str(spreadsheetNumber) + ':E' + str(spreadsheetNumber))) if not rolled[1].lower() in illegalNames: config['lastRoll'] = spreadsheetNumber saveConfig(config) send(bot, "<b>Rolled {}</b>\n{} - {} ({})\nSuggested by: {}". format(spreadsheetNumber, rolled[2].encode('utf-8'), rolled[4].encode('utf-8'), rolled[3].encode('utf-8'), rolled[1].encode('utf-8')), parse_mode="HTML") return else: send( bot, "Rolled {}. {} - illegal.".format( spreadsheetNumber, rolled[1].encode('utf-8'))) else: reply(update, "No suggestions found.") else: reply(update, "Another session is still on. I'm afraid I can't do that.")
def newAlbumSet(bot, config, artistName, albumName, year, suggested): config['isPlaying'] = True config['artist'] = artistName.encode('utf-8') config['album'] = albumName.encode('utf-8') config['track'] = "" text = "" if year is not None and suggested is not None: config['year'] = year.encode('utf-8') config['suggested'] = suggested.encode('utf-8') text = "#musictheatre New Album: {0} - {1} ({2}) [Suggested by: {3}]".format( config['artist'], config['album'], config['year'], config['suggested']) else: text = "#musictheatre New Album: {0} - {1}".format( config['artist'], config['album']) send(bot, text) saveConfig(config)
def roll(bot, update): if not isNewCommand(update): return if not checkAccess(update): return config = loadConfig() if config['isPlaying'] == True: reply(update, "Another session is still on. I'm afraid I can't do that.") return wks = auth() suggestionNames = list(filter(fNonEmpty, map(fValue, wks.range('B4:B100')))) illegalNames = list(map(fLower, list(filter(fNonEmpty, map(fValue, wks.range('G4:G9')))))) values = [] for i in range(len(suggestionNames)): name = suggestionNames[i].lower() if name not in illegalNames: values.append({"number": i+4, "name": name }) validSuggestionsCount = len(values) if validSuggestionsCount == 0: reply(update, "No suggestions found.") return # get random (favor older suggestions) rolled_from_valid = getRandom(validSuggestionsCount-1) result = values[rolled_from_valid]["number"] spreadsheetNumber = result rolled = list(map(fValue, wks.range('A'+str(spreadsheetNumber) +':E'+ str(spreadsheetNumber)))) config['lastRoll'] = spreadsheetNumber saveConfig(config) send(bot, "<b>Rolled {}</b>\n{} - {} ({})\nSuggested by: {}" .format( spreadsheetNumber, rolled[2], rolled[4], rolled[3], rolled[1]), parse_mode="HTML")
def tagMe(bot, update): if not isNewCommand(update): return if isNewSeeds(update): reply( update, "You have to private message me this command, because I am forbidden to initiate a chat with you." ) else: id = update.effective_user.id config = loadConfig() if 'tagList' not in config: config['tagList'] = [] if id not in config['tagList']: config['tagList'].append(id) bot.sendMessage( id, "You are now subscribed to /tag updates. Use /stop to unsubscribe." ) else: bot.sendMessage(id, "You are already subscribed to /tag updates.") saveConfig(config)