async def tweetReminder(ctx, member: discord.Member = None): if (Config.usingTwitterBot): if member is None: member = ctx.message.author if "moderator" in [y.name.lower() for y in member.roles ]: # Check if the user is a moderator offset = datetime.datetime.utcnow() - server.getLastTweet( ) # Get the time since last tweet if ( offset.total_seconds() >= Config.twitter_timeSinceTweet ): # Has **Config.twitter_timeSinceTweet** passed since the last tweet? timeDiff = JamInfo.getTimeDiff() # Get the time remaining timeLeft = "" if ( timeDiff < 0 ): # If timeDiff is negative the jam has already started -- Too late to tweet await bot.say("The jam has already started -- NOT TWEETING" ) formattedDiff = JamInfo.formatTime( timeDiff) # Get the formatted array if (formattedDiff[0] != ""): timeLeft = formattedDiff[0] + " " + formattedDiff[ 1] + " " + formattedDiff[2] # Day + Hour + Min elif (formattedDiff[1] != ""): timeLeft = formattedDiff[1] + " " + formattedDiff[ 2] # Hour + Min elif (formattedDiff[2] != ""): timeLeft = formattedDiff[2] + " " + formattedDiff[ 3] # Min + Sec else: timeLeft = formattedDiff[3] # Sec date = JamInfo.getUpcomingJamDate() value = str.format( "The #1hgj starts in {0} (Sat {1} UTC)! More info at onehourgamejam.com #gamedev #indiedev #gamejam", timeLeft, date) valueLen = value.count("") if valueLen <= 280: await bot.say(tweetBot.tweet(value)) else: await bot.say("Tweet error: Too many characters to tweet") else: await bot.say( "Not enough time has passed since last tweet (" + str(round((28800 - offset.total_seconds()) / 3600, 3)) + "h left)") else: print("Wrong role")
def jamReminderTask(): yield from bot.wait_until_ready() while not bot.is_closed: if Config.usingJamReminder: # get the current datetime now = datetime.datetime.utcnow() dtprint = now.strftime("%A %H:%M") ## datetime for printing dtcheck = now.strftime("%a %H") ## dateime object for checking jamReminderFile = io.open( Config.reminder_lastReminderFile, 'r' ) # Open the JamReminder file where the last reminder info is stored fileContents = jamReminderFile.read( ) # Read the contents of the file lastReminder = datetime.datetime.strptime( fileContents, "%Y-%m-%d %H:00:00").__str__( ) # Convert the JamReminder file into a datetime object nowFormatted = now.strftime("%Y-%m-%d %H:00:00").__str__( ) # Format 'now' into the readable format # check if the time is right AND if we already sent a message to the channel if dtcheck == Config.reminder_time and lastReminder != nowFormatted: channel = discord.Object( id=Config.reminder_channel ) ## this is the 1hgj discord announcement channel timeDiff = JamInfo.getTimeDiff() # Get the time remaining formattedDiff = JamInfo.formatTime( timeDiff) # Get the formatted array jamReminderFile = io.open( Config.reminder_lastReminderFile, 'w') # Reopen the JamReminder file in the WRITE mode jamReminderFile.write( nowFormatted ) # Write the time we sent the reminder (aka now) yield from bot.send_message( channel, "It is " + str(dtprint) + ". The One Hour Game Jam starts in " + formattedDiff[2] + " and " + formattedDiff[3] + ".") jamReminderFile.close() # Make sure to close the file stream yield from asyncio.sleep(60) # Run task every 60 seconds
async def theme(): current_theme = JamInfo.getCurrentTheme( ) # Get the theme of the ongoing jam if current_theme == "": response = Config.commands_themeNotAnnounced # If the ongoing jam JSON string is empty there isn't an ongoing jam ergo the theme hasn't been announced yet else: response = Config.commands_theme.format(current_theme) await bot.say(response)
def on_ready(): #Prints a message into a custom channel when it goes online if (Config.DEBUG): enabledFeatures = "\nDebug Enabled: {}\nDirectory: {}\nLastTheme Enabled: {}\nRandomTheme Enabled:{}\nEasterEggs Enabled: {}\nTwitterBot Enabled: {}\nJamReminder Enabled: {}".format( Config.DEBUG, Config.dir_path, Config.usingLastTheme, Config.usingRandomTheme, Config.usingEasterEggs, Config.usingTwitterBot, Config.usingJamReminder) channelID = discord.Object( id=Config.DEBUG_channel) # Get the channel ID of the debug channel yield from bot.send_message( channelID, "***I have come online (" + JamInfo.getNow().__str__() + ")***" + enabledFeatures)
async def time(): timeDiff = JamInfo.getTimeDiff() # Get the time remaining response = Config.commands_getTime_Upcoming if (timeDiff < 0): # If timeDiff is negative the jam has already started timeDiff = 3600 + timeDiff # Calculate the time until the jam ends response = Config.commands_getTime_Ongoing formattedDiff = JamInfo.formatTime(timeDiff) # Get the formatted array if (formattedDiff[0] != ""): response = response.format(formattedDiff[0] + " " + formattedDiff[1] + " " + formattedDiff[2]) # Day + Hour + Min elif (formattedDiff[1] != ""): response = response.format(formattedDiff[1] + " " + formattedDiff[2]) # Hour + Min elif (formattedDiff[2] != ""): response = response.format(formattedDiff[2] + " " + formattedDiff[3]) # Min + Sec else: response = response.format(formattedDiff[3]) # Sec await bot.say(response)
def on_ready(): """ Prints a message into the debug channel when it goes online """ if Config.DEBUG: features = "\nDebug Enabled: {}\nDirectory: {}\nLastTheme Enabled: {}\nEasterEggs Enabled: {" \ "}\nRandomTheme Enabled: {}\nTwitterBot Enabled: {}\nJamReminder Enabled: {}" enabled_features = features.format(Config.DEBUG, Config.directory_path, Config.usingLastTheme, Config.usingEasterEggs, Config.usingRandomTheme, Config.usingTwitterBot, Config.usingJamReminder) channel = discord.Object(id=Config.DEBUG_channel) yield from bot.send_message( channel, "***I have come online (" + JamInfo.getNow().__str__() + ")***" + enabled_features)
def jamReminderTask(): yield from bot.wait_until_ready() while not bot.is_closed: start_time = "8PM UTC, Midday PST, 3PM EST, 9PM CET and 7AM AEDT." # Daylight wasting # start_time = "8PM UTC, 1 PM PST, 4PM EST, 10PM CET and 6AM ACT." # Daylight savings next_jam_date = JamInfo.getUpcomingJamDate() tweet_content = "EMPTY" send_reminder = False # 24 hour reminder if check_time(next_jam_date - datetime.timedelta(hours=24)): tweet_content = "1 Hour Game Jam starts in 24h! That's at " + start_time + " https://onehourgamejam.com " + Config.twitter_hashtags # 16 hour reminder elif check_time(next_jam_date - datetime.timedelta(hours=16)): tweet_content = "1 Hour Game Jam starts in 16h! That's at " + start_time + " https://onehourgamejam.com " + Config.twitter_hashtags # 8 hour reminder elif check_time(next_jam_date - datetime.timedelta(hours=8)): tweet_content = "1 Hour Game Jam starts in 8h! That's at " + start_time + " https://onehourgamejam.com " + Config.twitter_hashtags # 4 hour reminder elif check_time(next_jam_date - datetime.timedelta(hours=4)): tweet_content = "1 Hour Game Jam starts in 4h! Participate at https://onehourgamejam.com " + Config.twitter_hashtags # 2 hour reminder elif check_time(next_jam_date - datetime.timedelta(hours=2)): tweet_content = "1 Hour Game Jam starts in 2h! Participate at https://onehourgamejam.com " + Config.twitter_hashtags # 1 hour reminder elif check_time(next_jam_date - datetime.timedelta(hours=1)): tweet_content = "1 Hour Game Jam starts in 1h! Join us on Discord at https://discord.gg/J86uTu9 " + Config.twitter_hashtags send_reminder = True # 20 min reminder elif check_time(next_jam_date - datetime.timedelta(minutes=20)): tweet_content = "1 Hour Game Jam starts in 20 minutes! Join us on Discord at https://discord.gg/J86uTu9 " + Config.twitter_hashtags # START reminder elif check_time(next_jam_date): jam_number = JamInfo.getCurrentJamNumber() jam_theme = JamInfo.getCurrentTheme() tweet_content = "1 hour game jam " + jam_number + " started. The theme is: '" + jam_theme + "'. Participate at https://onehourgamejam.com " + Config.twitter_hashtags # ---- Twitter ---- if Config.usingTwitterBot and Config.usingAutoTwitterBot and tweet_content != "EMPTY": tweetBot.tweet(tweet_content) yield from bot.send_message( discord.Object(id=Config.DEBUG_modChannel), "<@111890906055020544>Tweet sent\n||" + tweet_content + "||") # ---- Send Jam Reminder ---- if Config.usingJamReminder and send_reminder: yield from bot.send_message( discord.Object(id=Config.reminder_JamChannel), "@everyone The One Hour Game Jam starts within an hour! Hype<:lime:322433693111287838>!!" ) elif not Config.usingJamReminder and send_reminder: yield from bot.send_message( discord.Object(id=Config.DEBUG_modChannel), ":speak_no_evil: I tried sending out a reminder but Liam was like \"urm no u aren't\" :speak_no_evil:" ) yield from asyncio.sleep(60) # Run task every 60 seconds
async def now(): if Config.DEBUG: await bot.say("Current server time: " + JamInfo.getNow().__str__())
async def lastTheme(): if Config.usingLastTheme: await bot.say( Config.commands_getLastTheme.format(JamInfo.getLastTheme()))
async def now(): # Gets the 'now' from the One Hour Game Jam server if (Config.DEBUG): await bot.say("Current server time: " + JamInfo.getNow().__str__())