From 4056f60cd8e420769844c9866c78b3e951230a84 Mon Sep 17 00:00:00 2001 From: Rich Oberholtzer Date: Wed, 20 Jan 2021 21:55:42 -0500 Subject: [PATCH 01/51] duplicated statping functions for mmr monitor --- r0b3bot.py | 239 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 239 insertions(+) diff --git a/r0b3bot.py b/r0b3bot.py index 300ebd6..6060225 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -905,6 +905,245 @@ async def get_stp_status(service): if not found: return "service not found" +# +# Begin functions for MMR sub/alerts +# +@bot.command() +async def mmrsub(ctx, service = "NONE"): + + mmrsublist = {} # MMR Subscription list to be read in from file + # Structure of spsublist nested dictionary + # spsublist[service name][list of channel ids][a state value] + # dict = {'Plex': {'state' : 'online', 'channels' : ['1232', '43234']} + # 'Space Eingineers' : {'state' : online', 'channels' : ['2343', '54563']}} + # + mmrcurrentsub_request = [] # list of elements detailing the current sub request + datestring = datetime.now() + datestring = datestring.strftime("%m/%d/%Y-%H:%M:%S") + + # replace _ with sapces + service = service.replace("_"," ") + + print(f"[{datestring}]: {ctx.message.author.display_name} called '$mmrsub '{service}'''") + + # Only work on this if the user has supplied a service name to monitor, a value of NONE + # means nothing was specified + if service != "NONE" and service != "-list" and not service.startswith('-del '): + + print(f">> Querying status of '{service}' to see if it exists") + service_state = await get_stp_status(service) + + if service != "NONE": + + if service == "-list": + # List the serivces that this channel is subscribed to + # Read in mmrsublist + mmrsublist = '' + async with aiof.open('mmrsublist.dat', 'rb') as datafile: + pickled_mmrsublist = await datafile.read() + mmrsublist = pickle.loads(pickled_mmrsublist) + + for service in mmrsublist.keys(): + + for channel in mmrsublist[service]['channels']: + if channel == ctx.channel.id: + mmrsublist += f"'{service}' " + + await ctx.send(f"This channel is subscribed to: {sublist}") + + elif service.startswith('-del:'): + # Delete the service from this channels subscriptions + service_toremove = service[5:] + print(f"{service_toremove}") + + # Open the data file for read in + async with aiof.open('mmrsublist.dat', 'rb') as datafile: + pickled_mmrsublist = await datafile.read() + mmrsublist = pickle.loads(pickled_mmrsublist) + + # We haven't found either the channel or servic; mark as false + found_service = False + found_channel = False + + # Iterate through the service names in the data + for service in mmrsublist.keys(): + + # If the service we want to unsub from is the same as the service in the data, we need to search for the channel + if service.lower() == service_toremove.lower(): + + # We've found the service match, mark as true + found_service = True + + # Iterate through the channels that are subbed to this service + for channel in mmrsublist[service]['channels']: + + # If a channel listed in the service matches the current users channel id, we've found our match + if channel == ctx.channel.id: + + # Marking channel as found + found_channel = True + # Get the proper name of the service + service_toremove = service + #Remove the current users channel from this service + mmrsublist[service]['channels'].remove(ctx.channel.id) + # Break since we're done. + break + + # If we got to the point of finding the channel, we're done. + if found_channel: + break + + if found_service and found_channel: + print(">> Saving dictionary to mmrsublist.dat") + async with aiof.open('mmrsublist.dat', 'wb') as datafile: + pickled_mmrsublist = pickle.dumps(mmrsublist, protocol=4) + await datafile.write(pickled_mmrsublist) + #await datafile.fsync() + await datafile.flush() + await ctx.send(f"This channel is unsubscribed from '{service}' alerts.") + else: + await ctx.send(f"This channel is not subscribed to alerts for '{service_toremove}''") + + # If the service exists, proceed with adding it to the list. + elif service_state != "service not found": + + print(f">> '{service}' is a valid Hanlde on Whatismymmr.com.") + print(f">> Checking if it has already been subscribed to") + #await ctx.send(f"'{service_state['name']}' added to monitored services") + mmrcurrentsub_request.append(ctx.channel.id) + mmrcurrentsub_request.append(service_state['name']) + mmrcurrentsub_request.append("online") + print(f">> Channel ID: {mmrcurrentsub_request[0]}") + print(f">> Service Name: {mmrcurrentsub_request[1]}") + print(f">> Initial State to set: {mmrcurrentsub_request[2]}") + + # read in data file containing dict of subscriptions + print(">> Checking for mmrsublist.dat") + if os.path.exists('mmrsublist.dat'): + + print(">> Data file exists, reading it in.") + # Read in mmrsublist + async with aiof.open('mmrsublist.dat', 'rb') as datafile: + pickled_mmrsublist = await datafile.read() + mmrspsublist = pickle.loads(pickled_mmrsublist) + + print(f">> Checking if handle is already in datafile") + found_service = False + found_channel = False + for service in mmrsublist.keys(): + print(f">> Does {service.lower()} == {mmrcurrentsub_request[1].lower()}") + + if service.lower() == mmrcurrentsub_request[1].lower(): + found_service = True + # This service matched what the user is trying to subscribe to + # Now we need to check if this is for the same channel + print(f">> Found {service} in data file, checking for channel") + + for channel in mmrsublist[service]['channels']: + if channel == mmrcurrentsub_request[0]: + print(f">> This channel is already subscribed to {service}") + await ctx.send(f"This channel is already subscribed to {service} alerts") + found_channel = True + break + if not found_channel: + # Append the current channel id to the list for this service + print(f">> Adding handle '{mmrcurrentsub_request[1]}' to {ctx.channel.id}") + await ctx.send(f"{service} has been added to monitored handles for this channel") + mmrsublist[service]['channels'].append(mmrcurrentsub_request[0]) + break + + if not found_service: + # Append the current channel id to the list for this service + print(f">> Adding handle '{mmrcurrentsub_request[1]}' to {ctx.channel.id}") + await ctx.send(f"{mmrcurrentsub_request[1]} has been added to monitored handle for this channel") + #newsub = {} + #newsub[currentsub_request[1]] = {'state' : 'online', 'channels' : [currentsub_request[0]]} + mmrsublist[mmrcurrentsub_request[1]] = {'state' : 'online', 'channels' : [mmrcurrentsub_request[0]]} + + else: + + print(">> mmrsublist.dat does not exist, new file will be created") + + # append new subscription to dict + print(">> Creating new dictionary") + mmrsublist[mmrcurrentsub_request[1]] = {'state' : 'online', 'channels' : [mmrcurrentsub_request[0]]} + print(f">> {service} subscription has been saved") + await ctx.send(f"{service} has been added to monitored handles for this channel") + + #Write updated array to data file + print(">> Saving dictionary to mmrsublist.dat") + async with aiof.open('mmrsublist.dat', 'wb') as datafile: + pickled_mmrsublist = pickle.dumps(mmrsublist, protocol=4) + await datafile.write(pickled_mmrsublist) + #await datafile.fsync() + await datafile.flush() + + print(">> Done") + #await ctx.send(f"'{service_state['name']}' added to monitored services") + + else: + print(f">> '{service}' does not exist, cancelling subscription") + await ctx.send(f"{service} was not found") + +async def mmr_monitor(sublist): + + # Checks the services listed in spsublist for status change + # Sublist is a list of 3 items: + # - ctx (used to send alert to channel) + # - service (the name of the service to check) + # - status string (last status of the service, either 'online' or 'offline') + + ctx = sublist[0] + + + while True: + + status = await get_stp_status(spsublist[1]) + if status['online'] and spsublist[2] == "online": + # nothing has changed, no alert needed + await asyncio.sleep(1) + elif not status['online'] and spsublist[2] == "offline": + # again, nothing has changed no alert needed + await asyncio.sleep(1) + else: + print(f"Status of {status['name']}' has changed") + if status['online']: + embed = discord.Embed(title=f"{status['name']} Service Alert", description=f"{spsublist[1]} is Online!", color=0x00ff40) + await ctx.send(embed=embed) + #await ctx.send(f"{spsublist[1]} is Online!") + spsublist[2] = "online" + elif not status['online']: + embed = discord.Embed(title=f"{status['name']} Service Alert", description=f"{spsublist[1]} is Offline!", color=0xff2200) + await ctx.send(embed=embed) + #await ctx.send(f"{spsublist[1]} is Offline!") + spsublist[2] = "offline" + else: + embed = discord.Embed(title=f"{status['name']} Service Alert", description=f"{spsublist[1]} is in an unknown state!", color=0xffff00) + await ctx.send(embed=embed) + #await ctx.send(f"Unknown state for service {spsublist[1]}") + await asyncio.sleep(60) + +async def get_mmr_status(mmrhandle): + + # Get StatPing status via REST API + mmrhandle_array = requests.get(mmrURL, headers=mmrHEADERS) + found = False + + # spservice_array is json data, need to treat it as such + for handle in mmrhandle_array.json(): + + # using lower() to eliminate any case mismatch problems + if mmrhandle['name'].lower() == handle.lower(): + + found = True + return mmrhandle + + # Want to alert user if the service was not found + if not found: + return "Handle not found" +# +# +# @bot.command() async def help(ctx): -- 2.39.5 From affbf366a1e22b044b201d3ca549fe48009fc272 Mon Sep 17 00:00:00 2001 From: Rich Oberholtzer Date: Sun, 14 Feb 2021 21:37:17 -0500 Subject: [PATCH 02/51] adding base code for mmr_checker --- r0b3bot.py | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/r0b3bot.py b/r0b3bot.py index 6060225..a25f4cd 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1141,6 +1141,78 @@ async def get_mmr_status(mmrhandle): # Want to alert user if the service was not found if not found: return "Handle not found" + +async def MMR_Monitor(): + + # reads in "mmrsublist.dat" every 3 hours then iterates + # through to check for mmr status changes. This function will need to check + # that "spsublist.dat" exists and is not empty. This function should be called + # in bot.on_ready + + # read in data file containing list of subscriptions + while True: + print("MMR Monitor: Reading in mmrsublist.dat") + if os.path.exists('mmrsublist.dat'): + async with aiof.open('mmrsublist.dat', 'rb') as datafile: + pickled_mmrsublist = await datafile.read() + mmrsublist = pickle.loads(pickled_mmrsublist) + + for handle in mmrsublist.keys(): + # service used to be subscription + status = await get_mmr_status(handle) + print(f">> {handle} Online: {handle['online']} | Previous state: {mmrsublist[handle]['state']}") + if status != 'handle not found': + if status['online'] and mmrsublist[handle]['state'] == 'online': + + # nothing has changed, no alert needed + await asyncio.sleep(1) + elif not status['online'] and mmrsublist[handle]['state'] == "offline": + + # again, nothing has changed no alert needed + await asyncio.sleep(1) + else: + + print(f">> Status of '{handle}' has changed, notifying subscribed channels") + + if status['online']: + mmrsublist[handle]['state'] = 'online' + for channel in mmrsublist[handle]['channels']: + ctx = bot.get_channel(channel) + print(f">> Alerting {ctx} that {handle} is Online") + embed = discord.Embed(title=f"MMR Alert", description=f"{handle} is Online!", color=0x00ff40) + await ctx.send(embed=embed) + + elif not status['online']: + mmrsublist[handle]['state'] = 'offline' + for channel in mmrsublist[handle]['channels']: + ctx = bot.get_channel(channel) + print(f">> Alerting {ctx} that {handle} is Offline") + embed = discord.Embed(title=f"MMR Alert", description=f"{handle} is Offline!", color=0xff2200) + await ctx.send(embed=embed) + + else: + for channel in mmrsublist[handle]['channels']: + ctx = bot.get_channel(channel) + print(f">> Alerting {ctx} that {handle} is an Unknown state") + embed = discord.Embed(title=f"MMR Alert", description=f"{handle} is in an unknown state!", color=0xffff00) + await ctx.send(embed=embed) + print(">> Done") + + #new_spsublist.append(subscription) + + # Write status changes to spsublist.dat + async with aiof.open('mmrsublist.dat', 'wb') as datafile: + pickled_mmrsublist = pickle.dumps(mmrsublist) + await datafile.write(pickled_mmrsublist) + #await datafile.fsync() + await datafile.flush() + + else: + print(">> mmrsublist.dat does not exist, nothing to do.") + + # 10800 seconds == 3 hours :) + await asyncio.sleep(10800) + # # # -- 2.39.5 From fa2a34c951d0720f88b762878e4b4a33b7533168 Mon Sep 17 00:00:00 2001 From: Rich O Date: Fri, 19 Mar 2021 22:24:04 -0400 Subject: [PATCH 03/51] adding mmr api variable --- bot_config.conf.example | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot_config.conf.example b/bot_config.conf.example index af77115..b7804b1 100644 --- a/bot_config.conf.example +++ b/bot_config.conf.example @@ -18,4 +18,5 @@ hass_token = hass_light = octoprint_ip_address = statping_url = -statping_api_key = \ No newline at end of file +statping_api_key = +mmr_api_url = -- 2.39.5 From 544f7b583394004cac3940db300f2ae34c1925b5 Mon Sep 17 00:00:00 2001 From: Rich O Date: Fri, 19 Mar 2021 22:43:02 -0400 Subject: [PATCH 04/51] I think all of the necessary changes have been made to add the mmr checker... needs to test now? --- r0b3bot.py | 137 ++++++++++++++++++++++++++--------------------------- 1 file changed, 68 insertions(+), 69 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index a25f4cd..5bc9785 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -61,6 +61,12 @@ statpingHEADERS = { 'content-type': 'application/json', } +mmrURLBASE = ('bot-config', 'mmr_api_url') +mmrHEADERS = { + 'User-Agent': 'Linux:com.r0b3bot:v.01a' + 'content-type': 'application/json' +} + # Configure bot bot = commands.Bot(command_prefix=BOT_COMMAND_PREFIX, description='A derpy derp of a bot.') @@ -914,7 +920,7 @@ async def mmrsub(ctx, service = "NONE"): mmrsublist = {} # MMR Subscription list to be read in from file # Structure of spsublist nested dictionary # spsublist[service name][list of channel ids][a state value] - # dict = {'Plex': {'state' : 'online', 'channels' : ['1232', '43234']} + # dict = {'Handle': {'AvgRank' : 'value', 'channels' : ['1232', '43234']} # 'Space Eingineers' : {'state' : online', 'channels' : ['2343', '54563']}} # mmrcurrentsub_request = [] # list of elements detailing the current sub request @@ -922,20 +928,20 @@ async def mmrsub(ctx, service = "NONE"): datestring = datestring.strftime("%m/%d/%Y-%H:%M:%S") # replace _ with sapces - service = service.replace("_"," ") + handle = handle.replace("_"," ") - print(f"[{datestring}]: {ctx.message.author.display_name} called '$mmrsub '{service}'''") + print(f"[{datestring}]: {ctx.message.author.display_name} called '$mmrsub '{handle}'''") # Only work on this if the user has supplied a service name to monitor, a value of NONE # means nothing was specified - if service != "NONE" and service != "-list" and not service.startswith('-del '): + if handle != "NONE" and handle != "-list" and not handle.startswith('-del '): - print(f">> Querying status of '{service}' to see if it exists") - service_state = await get_stp_status(service) + print(f">> Querying status of '{handle}' to see if it exists") + service_state = await get_stp_status(handle) - if service != "NONE": + if handle != "NONE": - if service == "-list": + if handle == "-list": # List the serivces that this channel is subscribed to # Read in mmrsublist mmrsublist = '' @@ -943,18 +949,18 @@ async def mmrsub(ctx, service = "NONE"): pickled_mmrsublist = await datafile.read() mmrsublist = pickle.loads(pickled_mmrsublist) - for service in mmrsublist.keys(): + for handle in mmrsublist.keys(): - for channel in mmrsublist[service]['channels']: + for channel in mmrsublist[handle]['channels']: if channel == ctx.channel.id: - mmrsublist += f"'{service}' " + mmrsublist += f"'{handle}' " - await ctx.send(f"This channel is subscribed to: {sublist}") + await ctx.send(f"This channel is subscribed to: {mmrsublist}") - elif service.startswith('-del:'): + elif handle.startswith('-del:'): # Delete the service from this channels subscriptions - service_toremove = service[5:] - print(f"{service_toremove}") + handle_toremove = handle[5:] + print(f"{handle_toremove}") # Open the data file for read in async with aiof.open('mmrsublist.dat', 'rb') as datafile: @@ -962,20 +968,20 @@ async def mmrsub(ctx, service = "NONE"): mmrsublist = pickle.loads(pickled_mmrsublist) # We haven't found either the channel or servic; mark as false - found_service = False + found_handle = False found_channel = False # Iterate through the service names in the data - for service in mmrsublist.keys(): + for handle in mmrsublist.keys(): # If the service we want to unsub from is the same as the service in the data, we need to search for the channel - if service.lower() == service_toremove.lower(): + if handle.lower() == handle_toremove.lower(): # We've found the service match, mark as true - found_service = True + found_handle = True # Iterate through the channels that are subbed to this service - for channel in mmrsublist[service]['channels']: + for channel in mmrsublist[handle]['channels']: # If a channel listed in the service matches the current users channel id, we've found our match if channel == ctx.channel.id: @@ -983,9 +989,9 @@ async def mmrsub(ctx, service = "NONE"): # Marking channel as found found_channel = True # Get the proper name of the service - service_toremove = service + handle_toremove = service #Remove the current users channel from this service - mmrsublist[service]['channels'].remove(ctx.channel.id) + mmrsublist[handle]['channels'].remove(ctx.channel.id) # Break since we're done. break @@ -993,21 +999,21 @@ async def mmrsub(ctx, service = "NONE"): if found_channel: break - if found_service and found_channel: + if found_handle and found_channel: print(">> Saving dictionary to mmrsublist.dat") async with aiof.open('mmrsublist.dat', 'wb') as datafile: pickled_mmrsublist = pickle.dumps(mmrsublist, protocol=4) await datafile.write(pickled_mmrsublist) #await datafile.fsync() await datafile.flush() - await ctx.send(f"This channel is unsubscribed from '{service}' alerts.") + await ctx.send(f"This channel is unsubscribed from '{handle}' alerts.") else: - await ctx.send(f"This channel is not subscribed to alerts for '{service_toremove}''") + await ctx.send(f"This channel is not subscribed to alerts for '{handle_toremove}''") # If the service exists, proceed with adding it to the list. - elif service_state != "service not found": + elif handle_state != "service not found": - print(f">> '{service}' is a valid Hanlde on Whatismymmr.com.") + print(f">> '{handle}' is a valid Hanlde on Whatismymmr.com.") print(f">> Checking if it has already been subscribed to") #await ctx.send(f"'{service_state['name']}' added to monitored services") mmrcurrentsub_request.append(ctx.channel.id) @@ -1028,31 +1034,31 @@ async def mmrsub(ctx, service = "NONE"): mmrspsublist = pickle.loads(pickled_mmrsublist) print(f">> Checking if handle is already in datafile") - found_service = False + found_handle = False found_channel = False for service in mmrsublist.keys(): - print(f">> Does {service.lower()} == {mmrcurrentsub_request[1].lower()}") + print(f">> Does {handle.lower()} == {mmrcurrentsub_request[1].lower()}") - if service.lower() == mmrcurrentsub_request[1].lower(): - found_service = True + if handle.lower() == mmrcurrentsub_request[1].lower(): + found_handle = True # This service matched what the user is trying to subscribe to # Now we need to check if this is for the same channel - print(f">> Found {service} in data file, checking for channel") + print(f">> Found {handle} in data file, checking for channel") - for channel in mmrsublist[service]['channels']: + for channel in mmrsublist[handle]['channels']: if channel == mmrcurrentsub_request[0]: - print(f">> This channel is already subscribed to {service}") - await ctx.send(f"This channel is already subscribed to {service} alerts") + print(f">> This channel is already subscribed to {handle}") + await ctx.send(f"This channel is already subscribed to {handle} alerts") found_channel = True break if not found_channel: # Append the current channel id to the list for this service print(f">> Adding handle '{mmrcurrentsub_request[1]}' to {ctx.channel.id}") - await ctx.send(f"{service} has been added to monitored handles for this channel") + await ctx.send(f"{handle} has been added to monitored handles for this channel") mmrsublist[service]['channels'].append(mmrcurrentsub_request[0]) break - if not found_service: + if not found_handle: # Append the current channel id to the list for this service print(f">> Adding handle '{mmrcurrentsub_request[1]}' to {ctx.channel.id}") await ctx.send(f"{mmrcurrentsub_request[1]} has been added to monitored handle for this channel") @@ -1067,8 +1073,8 @@ async def mmrsub(ctx, service = "NONE"): # append new subscription to dict print(">> Creating new dictionary") mmrsublist[mmrcurrentsub_request[1]] = {'state' : 'online', 'channels' : [mmrcurrentsub_request[0]]} - print(f">> {service} subscription has been saved") - await ctx.send(f"{service} has been added to monitored handles for this channel") + print(f">> {handle} subscription has been saved") + await ctx.send(f"{handle} has been added to monitored handles for this channel") #Write updated array to data file print(">> Saving dictionary to mmrsublist.dat") @@ -1082,8 +1088,8 @@ async def mmrsub(ctx, service = "NONE"): #await ctx.send(f"'{service_state['name']}' added to monitored services") else: - print(f">> '{service}' does not exist, cancelling subscription") - await ctx.send(f"{service} was not found") + print(f">> '{handle}' does not exist, cancelling subscription") + await ctx.send(f"{handle} was not found") async def mmr_monitor(sublist): @@ -1126,21 +1132,14 @@ async def mmr_monitor(sublist): async def get_mmr_status(mmrhandle): # Get StatPing status via REST API - mmrhandle_array = requests.get(mmrURL, headers=mmrHEADERS) - found = False - - # spservice_array is json data, need to treat it as such - for handle in mmrhandle_array.json(): - - # using lower() to eliminate any case mismatch problems - if mmrhandle['name'].lower() == handle.lower(): - - found = True - return mmrhandle - - # Want to alert user if the service was not found - if not found: - return "Handle not found" + #need to replace spaces with %20 before just inserting into URL + mmrhandle.replace(" ", "%20") + mmrURL = mmrURLBASE + mmrhandle + response = requests.get(mmrURL, headers=mmrHEADERS) + mmr_stats = json.loads(response.text) + + return mmr_stats['ranked']['avg'] + async def MMR_Monitor(): @@ -1160,13 +1159,13 @@ async def MMR_Monitor(): for handle in mmrsublist.keys(): # service used to be subscription status = await get_mmr_status(handle) - print(f">> {handle} Online: {handle['online']} | Previous state: {mmrsublist[handle]['state']}") + print(f">> {handle} Average Rank: {handle['AvgRank']} | Previous state: {mmrsublist[handle]['AvgRank']}") if status != 'handle not found': - if status['online'] and mmrsublist[handle]['state'] == 'online': + if status['AvgRank'] == mmrsublist[handle]['AvgTank']: # nothing has changed, no alert needed await asyncio.sleep(1) - elif not status['online'] and mmrsublist[handle]['state'] == "offline": + elif not status['AvgRank'] != mmrsublist[handle]['AvgRank']: # again, nothing has changed no alert needed await asyncio.sleep(1) @@ -1174,27 +1173,27 @@ async def MMR_Monitor(): print(f">> Status of '{handle}' has changed, notifying subscribed channels") - if status['online']: - mmrsublist[handle]['state'] = 'online' + if status['AvgRank'] > mmrsublist[handle]['AvgRank']: + mmrsublist[handle]['AvgRank'] = status['AvgRank'] for channel in mmrsublist[handle]['channels']: ctx = bot.get_channel(channel) - print(f">> Alerting {ctx} that {handle} is Online") - embed = discord.Embed(title=f"MMR Alert", description=f"{handle} is Online!", color=0x00ff40) + print(f">> Alerting {ctx} that {handle} Average Rank has Increased!") + embed = discord.Embed(title=f"MMR Alert", description=f"{handle}'s rank is {status['AvgRank']}", color=0x00ff40) await ctx.send(embed=embed) - elif not status['online']: - mmrsublist[handle]['state'] = 'offline' + elif status['AvgRank'] < mmrsublist[handle]['AvgRank']: + mmrsublist[handle]['state'] = status['AvgRank'] for channel in mmrsublist[handle]['channels']: ctx = bot.get_channel(channel) - print(f">> Alerting {ctx} that {handle} is Offline") - embed = discord.Embed(title=f"MMR Alert", description=f"{handle} is Offline!", color=0xff2200) + print(f">> Alerting {ctx} that {handle}'s Average Rank has Decreased!") + embed = discord.Embed(title=f"MMR Alert", description=f"{handle}'s rank is {status['AvgRank']}", color=0xff2200) await ctx.send(embed=embed) else: for channel in mmrsublist[handle]['channels']: ctx = bot.get_channel(channel) - print(f">> Alerting {ctx} that {handle} is an Unknown state") - embed = discord.Embed(title=f"MMR Alert", description=f"{handle} is in an unknown state!", color=0xffff00) + print(f">> Alerting {ctx} that {handle}'s rank is an unknown state") + embed = discord.Embed(title=f"MMR Alert", description=f"{handle}'s rank is in an unknown state!", color=0xffff00) await ctx.send(embed=embed) print(">> Done") -- 2.39.5 From 4cf45b26843ba30b672188674bd2459e69866924 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 10:01:34 -0400 Subject: [PATCH 05/51] added enable/disable options for mmr checker and statping monitor --- bot_config.conf.example | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bot_config.conf.example b/bot_config.conf.example index b7804b1..2697304 100644 --- a/bot_config.conf.example +++ b/bot_config.conf.example @@ -17,6 +17,8 @@ hass_url = hass_token = hass_light = octoprint_ip_address = +statping_enable = statping_url = statping_api_key = +mmr_checker_enable = mmr_api_url = -- 2.39.5 From cf3757ce114c7c6e7d52def09f9b2857e9ba63d2 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 10:02:08 -0400 Subject: [PATCH 06/51] added enable/disable check before starting mmr checker and statping monitor --- r0b3bot.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index 5bc9785..dd921bd 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -53,6 +53,7 @@ hassHEADERS = { OCTOPRINT_IP_ADDRESS = config.get('bot-config', 'octoprint_ip_address') DISCORD_AUTH_TOKEN = config.get('bot-config', 'discord_auth_token') BOT_COMMAND_PREFIX = config.get('bot-config', 'bot_command_prefix') +statping_enable = config.get('bot-config', 'statping_enable') STATPING_URL = config.get('bot-config', 'statping_url') STATPING_API_KEY = config.get('bot-config', 'statping_api_key') statpingURL = STATPING_URL + "/api/services" @@ -61,6 +62,7 @@ statpingHEADERS = { 'content-type': 'application/json', } +mmr_checker_enable = config.get('bot-config', 'mmr_checker_enable') mmrURLBASE = ('bot-config', 'mmr_api_url') mmrHEADERS = { 'User-Agent': 'Linux:com.r0b3bot:v.01a' @@ -95,8 +97,12 @@ async def on_ready(): runtime = time.time() - start_time if runtime <= 15: #Run StatPing_Monitor - print("Starting StatPing Monitor.") - await StatPing_Monitor() + if statping_enable: + print("Statping Monitor enabled, starting StatPing Monitor.") + await StatPing_Monitor() + if mmr_checker_enable: + print("MMR Checker enables, starting MMR Checker.") + await MMR_Monitor() else: print(f">> Bot has been running for more than {int(runtime)} seconds. Not restarting monitor.") -- 2.39.5 From 55419dbafb8aabdf72fc803bfeee88920de2f83e Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 10:03:45 -0400 Subject: [PATCH 07/51] correcting syntax error --- r0b3bot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index dd921bd..8a3d2bd 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -65,8 +65,8 @@ statpingHEADERS = { mmr_checker_enable = config.get('bot-config', 'mmr_checker_enable') mmrURLBASE = ('bot-config', 'mmr_api_url') mmrHEADERS = { - 'User-Agent': 'Linux:com.r0b3bot:v.01a' - 'content-type': 'application/json' + 'User-Agent': 'Linux:com.r0b3bot:v.01a', + 'content-type': 'application/json', } # Configure bot -- 2.39.5 From 0cf348570bed6d0c14c323dd6b7f8055b1de293e Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 11:39:17 -0400 Subject: [PATCH 08/51] tweaks --- r0b3bot.py | 58 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index 8a3d2bd..02ffe8b 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -63,7 +63,7 @@ statpingHEADERS = { } mmr_checker_enable = config.get('bot-config', 'mmr_checker_enable') -mmrURLBASE = ('bot-config', 'mmr_api_url') +mmrURLBASE = config.get('bot-config', 'mmr_api_url') mmrHEADERS = { 'User-Agent': 'Linux:com.r0b3bot:v.01a', 'content-type': 'application/json', @@ -77,10 +77,12 @@ print(f"HomeAssistant URL: {hassURL}") print(f"HomeAssistant URL HEADERS: {hassHEADERS}") print(f"HomeAssistant Light: {HASS_LIGHT}") print(f"OctoPrint IP Address: {OCTOPRINT_IP_ADDRESS}") +print(f"StatPing Monitor Enabled: {statping_enable}") print(f"StatPing Server: {STATPING_URL}") print(f"StatPing API Key: {STATPING_API_KEY}") print(f"StatPing URL Headers: {statpingHEADERS}") - +print(f"MMR Checker Enabled: {mmr_checker_enable}") +print(f"MMR Checker URL BASE: {mmrURLBASE}") # On Ready @bot.event async def on_ready(): @@ -97,15 +99,23 @@ async def on_ready(): runtime = time.time() - start_time if runtime <= 15: #Run StatPing_Monitor - if statping_enable: + if statping_enable == 'True': print("Statping Monitor enabled, starting StatPing Monitor.") await StatPing_Monitor() - if mmr_checker_enable: - print("MMR Checker enables, starting MMR Checker.") - await MMR_Monitor() + + else: - print(f">> Bot has been running for more than {int(runtime)} seconds. Not restarting monitor.") + print(f">> Bot has been running for more than {int(runtime)} seconds. Not starting StatPing Monitor.") + + #Run MMR Montor + if runtime <= 15: + if mmr_checker_enable == 'True': + print("MMR Checker enabled, starting MMR Checker.") + await MMR_Monitor() + else: + print(f">> Bot has been running for more than {int(runtime)} seconds. Not starting MMR Checker.") + print(">> Startup complete.") @bot.command() async def greetings(ctx): @@ -921,7 +931,7 @@ async def get_stp_status(service): # Begin functions for MMR sub/alerts # @bot.command() -async def mmrsub(ctx, service = "NONE"): +async def mmrsub(ctx, handle = "NONE"): mmrsublist = {} # MMR Subscription list to be read in from file # Structure of spsublist nested dictionary @@ -943,7 +953,7 @@ async def mmrsub(ctx, service = "NONE"): if handle != "NONE" and handle != "-list" and not handle.startswith('-del '): print(f">> Querying status of '{handle}' to see if it exists") - service_state = await get_stp_status(handle) + handle_state = await get_mmr_status(handle) if handle != "NONE": @@ -1023,11 +1033,11 @@ async def mmrsub(ctx, service = "NONE"): print(f">> Checking if it has already been subscribed to") #await ctx.send(f"'{service_state['name']}' added to monitored services") mmrcurrentsub_request.append(ctx.channel.id) - mmrcurrentsub_request.append(service_state['name']) - mmrcurrentsub_request.append("online") + mmrcurrentsub_request.append(handle) + mmrcurrentsub_request.append(handle_state) print(f">> Channel ID: {mmrcurrentsub_request[0]}") - print(f">> Service Name: {mmrcurrentsub_request[1]}") - print(f">> Initial State to set: {mmrcurrentsub_request[2]}") + print(f">> Handle: {mmrcurrentsub_request[1]}") + print(f">> Current Ranked Average: {mmrcurrentsub_request[2]}") # read in data file containing dict of subscriptions print(">> Checking for mmrsublist.dat") @@ -1042,7 +1052,7 @@ async def mmrsub(ctx, service = "NONE"): print(f">> Checking if handle is already in datafile") found_handle = False found_channel = False - for service in mmrsublist.keys(): + for handle in mmrsublist.keys(): print(f">> Does {handle.lower()} == {mmrcurrentsub_request[1].lower()}") if handle.lower() == mmrcurrentsub_request[1].lower(): @@ -1070,7 +1080,7 @@ async def mmrsub(ctx, service = "NONE"): await ctx.send(f"{mmrcurrentsub_request[1]} has been added to monitored handle for this channel") #newsub = {} #newsub[currentsub_request[1]] = {'state' : 'online', 'channels' : [currentsub_request[0]]} - mmrsublist[mmrcurrentsub_request[1]] = {'state' : 'online', 'channels' : [mmrcurrentsub_request[0]]} + mmrsublist[mmrcurrentsub_request[1]] = {'AvgRank' : mmrcurrentsub_request[2], 'channels' : [mmrcurrentsub_request[0]]} else: @@ -1078,7 +1088,7 @@ async def mmrsub(ctx, service = "NONE"): # append new subscription to dict print(">> Creating new dictionary") - mmrsublist[mmrcurrentsub_request[1]] = {'state' : 'online', 'channels' : [mmrcurrentsub_request[0]]} + mmrsublist[mmrcurrentsub_request[1]] = {'AvgRank' : mmrcurrentsub_request[2], 'channels' : [mmrcurrentsub_request[0]]} print(f">> {handle} subscription has been saved") await ctx.send(f"{handle} has been added to monitored handles for this channel") @@ -1133,14 +1143,15 @@ async def mmr_monitor(sublist): embed = discord.Embed(title=f"{status['name']} Service Alert", description=f"{spsublist[1]} is in an unknown state!", color=0xffff00) await ctx.send(embed=embed) #await ctx.send(f"Unknown state for service {spsublist[1]}") - await asyncio.sleep(60) + #Sleep for 3 hours + await asyncio.sleep(10800) async def get_mmr_status(mmrhandle): # Get StatPing status via REST API #need to replace spaces with %20 before just inserting into URL mmrhandle.replace(" ", "%20") - mmrURL = mmrURLBASE + mmrhandle + mmrURL = ''.join(mmrURLBASE) + mmrhandle response = requests.get(mmrURL, headers=mmrHEADERS) mmr_stats = json.loads(response.text) @@ -1165,13 +1176,14 @@ async def MMR_Monitor(): for handle in mmrsublist.keys(): # service used to be subscription status = await get_mmr_status(handle) - print(f">> {handle} Average Rank: {handle['AvgRank']} | Previous state: {mmrsublist[handle]['AvgRank']}") + print(f"{handle} | {mmrsublist[handle]}") + print(f">> {handle} Average Rank: {status} | Previous state: {mmrsublist[handle]['AvgRank']}") if status != 'handle not found': - if status['AvgRank'] == mmrsublist[handle]['AvgTank']: + if status == mmrsublist[handle]['AvgRank']: # nothing has changed, no alert needed await asyncio.sleep(1) - elif not status['AvgRank'] != mmrsublist[handle]['AvgRank']: + elif not status != mmrsublist[handle]['AvgRank']: # again, nothing has changed no alert needed await asyncio.sleep(1) @@ -1179,7 +1191,7 @@ async def MMR_Monitor(): print(f">> Status of '{handle}' has changed, notifying subscribed channels") - if status['AvgRank'] > mmrsublist[handle]['AvgRank']: + if status > mmrsublist[handle]['AvgRank']: mmrsublist[handle]['AvgRank'] = status['AvgRank'] for channel in mmrsublist[handle]['channels']: ctx = bot.get_channel(channel) @@ -1187,7 +1199,7 @@ async def MMR_Monitor(): embed = discord.Embed(title=f"MMR Alert", description=f"{handle}'s rank is {status['AvgRank']}", color=0x00ff40) await ctx.send(embed=embed) - elif status['AvgRank'] < mmrsublist[handle]['AvgRank']: + elif status < mmrsublist[handle]['AvgRank']: mmrsublist[handle]['state'] = status['AvgRank'] for channel in mmrsublist[handle]['channels']: ctx = bot.get_channel(channel) -- 2.39.5 From 1e496efbee44b0e36b8908a134a0359c0a4ebfbe Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 12:11:30 -0400 Subject: [PATCH 09/51] added interval option for mmr checker, cleaned up some output --- bot_config.conf.example | 1 + r0b3bot.py | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/bot_config.conf.example b/bot_config.conf.example index 2697304..a894807 100644 --- a/bot_config.conf.example +++ b/bot_config.conf.example @@ -21,4 +21,5 @@ statping_enable = statping_url = statping_api_key = mmr_checker_enable = +mmr_checker_interval = mmr_api_url = diff --git a/r0b3bot.py b/r0b3bot.py index 02ffe8b..1d5897e 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -63,6 +63,7 @@ statpingHEADERS = { } mmr_checker_enable = config.get('bot-config', 'mmr_checker_enable') +mmr_checker_interval = config.get('bot-config', 'mmr_checker_interval') mmrURLBASE = config.get('bot-config', 'mmr_api_url') mmrHEADERS = { 'User-Agent': 'Linux:com.r0b3bot:v.01a', @@ -73,16 +74,20 @@ mmrHEADERS = { bot = commands.Bot(command_prefix=BOT_COMMAND_PREFIX, description='A derpy derp of a bot.') # Printing configuration details to console -print(f"HomeAssistant URL: {hassURL}") -print(f"HomeAssistant URL HEADERS: {hassHEADERS}") -print(f"HomeAssistant Light: {HASS_LIGHT}") -print(f"OctoPrint IP Address: {OCTOPRINT_IP_ADDRESS}") -print(f"StatPing Monitor Enabled: {statping_enable}") -print(f"StatPing Server: {STATPING_URL}") -print(f"StatPing API Key: {STATPING_API_KEY}") -print(f"StatPing URL Headers: {statpingHEADERS}") -print(f"MMR Checker Enabled: {mmr_checker_enable}") -print(f"MMR Checker URL BASE: {mmrURLBASE}") +print("=== 3D Printer Status config ===") +print(f" HomeAssistant URL: {hassURL}") +print(f" HomeAssistant URL HEADERS: {hassHEADERS}") +print(f" HomeAssistant Light: {HASS_LIGHT}") +print(f" OctoPrint IP Address: {OCTOPRINT_IP_ADDRESS}") +print("=== StatPing Monitor Config ===") +print(f" Enabled: {statping_enable}") +print(f" SServer: {STATPING_URL}") +print(f" API Key: {STATPING_API_KEY}") +print(f" URL Headers: {statpingHEADERS}") +print("=== MMR Checker Config ===") +print(f" Enabled: {mmr_checker_enable}") +print(f" Checker Interval: {mmr_checker_interval}") +print(f" API URL BASE: {mmrURLBASE}") # On Ready @bot.event async def on_ready(): @@ -1228,7 +1233,7 @@ async def MMR_Monitor(): print(">> mmrsublist.dat does not exist, nothing to do.") # 10800 seconds == 3 hours :) - await asyncio.sleep(10800) + await asyncio.sleep(mmr_checker_interval) # # -- 2.39.5 From 7628f8d1aeb827d331bf7c3c84d6768303b3f6be Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 12:14:52 -0400 Subject: [PATCH 10/51] setting variable to int --- r0b3bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r0b3bot.py b/r0b3bot.py index 1d5897e..c88da21 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1233,7 +1233,7 @@ async def MMR_Monitor(): print(">> mmrsublist.dat does not exist, nothing to do.") # 10800 seconds == 3 hours :) - await asyncio.sleep(mmr_checker_interval) + await asyncio.sleep(int(mmr_checker_interval)) # # -- 2.39.5 From 5b917e032f538d624b872175f097730fd1510c77 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 12:16:36 -0400 Subject: [PATCH 11/51] fixing minor typo --- r0b3bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r0b3bot.py b/r0b3bot.py index c88da21..fecfddd 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -81,7 +81,7 @@ print(f" HomeAssistant Light: {HASS_LIGHT}") print(f" OctoPrint IP Address: {OCTOPRINT_IP_ADDRESS}") print("=== StatPing Monitor Config ===") print(f" Enabled: {statping_enable}") -print(f" SServer: {STATPING_URL}") +print(f" Server: {STATPING_URL}") print(f" API Key: {STATPING_API_KEY}") print(f" URL Headers: {statpingHEADERS}") print("=== MMR Checker Config ===") -- 2.39.5 From f6e15d9c35cd7d3c1a5bb375376c0c0a456a10f5 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 12:38:21 -0400 Subject: [PATCH 12/51] output formatting --- r0b3bot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index fecfddd..4eb9f91 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1182,7 +1182,7 @@ async def MMR_Monitor(): # service used to be subscription status = await get_mmr_status(handle) print(f"{handle} | {mmrsublist[handle]}") - print(f">> {handle} Average Rank: {status} | Previous state: {mmrsublist[handle]['AvgRank']}") + print(f">> '{handle}'s Average Rank: {status} | Previous state: {mmrsublist[handle]['AvgRank']}") if status != 'handle not found': if status == mmrsublist[handle]['AvgRank']: @@ -1200,7 +1200,7 @@ async def MMR_Monitor(): mmrsublist[handle]['AvgRank'] = status['AvgRank'] for channel in mmrsublist[handle]['channels']: ctx = bot.get_channel(channel) - print(f">> Alerting {ctx} that {handle} Average Rank has Increased!") + print(f">> Alerting {ctx} that '{handle}'s Average Rank has Increased!") embed = discord.Embed(title=f"MMR Alert", description=f"{handle}'s rank is {status['AvgRank']}", color=0x00ff40) await ctx.send(embed=embed) @@ -1208,7 +1208,7 @@ async def MMR_Monitor(): mmrsublist[handle]['state'] = status['AvgRank'] for channel in mmrsublist[handle]['channels']: ctx = bot.get_channel(channel) - print(f">> Alerting {ctx} that {handle}'s Average Rank has Decreased!") + print(f">> Alerting {ctx} that '{handle}'s Average Rank has Decreased!") embed = discord.Embed(title=f"MMR Alert", description=f"{handle}'s rank is {status['AvgRank']}", color=0xff2200) await ctx.send(embed=embed) -- 2.39.5 From 0950092f6d7c9e41abfa6dc33df2fe92c61c5428 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 12:46:47 -0400 Subject: [PATCH 13/51] more tweaks to output --- r0b3bot.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index 4eb9f91..6cca0f7 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -88,15 +88,16 @@ print("=== MMR Checker Config ===") print(f" Enabled: {mmr_checker_enable}") print(f" Checker Interval: {mmr_checker_interval}") print(f" API URL BASE: {mmrURLBASE}") + # On Ready @bot.event async def on_ready(): print('Logged in as') - print(bot.user.name) - print(bot.user.id) - print('------') - print("Setting activity to 'Listenting to your commands'") - activity = discord.Activity(name="your $commands",type=discord.ActivityType.listening) + print(f" User: {bot.user.name}") + print(f" ID: {bot.user.id}") + print(f"------\n") + print(f"Setting activity to 'Listenting to your {BOT_COMMAND_PREFIX}commands'") + activity = discord.Activity(name=f"your {BOT_COMMAND_PREFIX}commands",type=discord.ActivityType.listening) await bot.change_presence(activity=activity) -- 2.39.5 From 803e8d552dc0c53a28bb76352a4d8a434a90d49d Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 12:48:19 -0400 Subject: [PATCH 14/51] more tweaks to output --- r0b3bot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/r0b3bot.py b/r0b3bot.py index 6cca0f7..4a3b35d 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -92,6 +92,7 @@ print(f" API URL BASE: {mmrURLBASE}") # On Ready @bot.event async def on_ready(): + print(":::: Config Loaded ::::\n") print('Logged in as') print(f" User: {bot.user.name}") print(f" ID: {bot.user.id}") -- 2.39.5 From 2cabbbf6f11182a6bc19b913eb1b074f25088a1e Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 12:49:19 -0400 Subject: [PATCH 15/51] more tweaks to output --- r0b3bot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index 4a3b35d..e0efc3e 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -92,11 +92,11 @@ print(f" API URL BASE: {mmrURLBASE}") # On Ready @bot.event async def on_ready(): - print(":::: Config Loaded ::::\n") + print("\n:::: Config Loaded ::::\n") print('Logged in as') print(f" User: {bot.user.name}") print(f" ID: {bot.user.id}") - print(f"------\n") + print(f"\n\n") print(f"Setting activity to 'Listenting to your {BOT_COMMAND_PREFIX}commands'") activity = discord.Activity(name=f"your {BOT_COMMAND_PREFIX}commands",type=discord.ActivityType.listening) await bot.change_presence(activity=activity) -- 2.39.5 From 5c0e61d4666e70d8722fcd1ffd629481b3023052 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 12:51:43 -0400 Subject: [PATCH 16/51] adding newlines --- r0b3bot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index e0efc3e..dd4fc40 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -79,12 +79,12 @@ print(f" HomeAssistant URL: {hassURL}") print(f" HomeAssistant URL HEADERS: {hassHEADERS}") print(f" HomeAssistant Light: {HASS_LIGHT}") print(f" OctoPrint IP Address: {OCTOPRINT_IP_ADDRESS}") -print("=== StatPing Monitor Config ===") +print("\n=== StatPing Monitor Config ===") print(f" Enabled: {statping_enable}") print(f" Server: {STATPING_URL}") print(f" API Key: {STATPING_API_KEY}") print(f" URL Headers: {statpingHEADERS}") -print("=== MMR Checker Config ===") +print("\n=== MMR Checker Config ===") print(f" Enabled: {mmr_checker_enable}") print(f" Checker Interval: {mmr_checker_interval}") print(f" API URL BASE: {mmrURLBASE}") -- 2.39.5 From ab7009e43fca9bc2b0aa9951cf35512ae3824ce4 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 16:25:36 -0400 Subject: [PATCH 17/51] fixing assignment --- r0b3bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r0b3bot.py b/r0b3bot.py index dd4fc40..61b0d87 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1207,7 +1207,7 @@ async def MMR_Monitor(): await ctx.send(embed=embed) elif status < mmrsublist[handle]['AvgRank']: - mmrsublist[handle]['state'] = status['AvgRank'] + mmrsublist[handle]['AvgRank'] = status['AvgRank'] for channel in mmrsublist[handle]['channels']: ctx = bot.get_channel(channel) print(f">> Alerting {ctx} that '{handle}'s Average Rank has Decreased!") -- 2.39.5 From 0207424d328995d69f01eefb10ca8fda803109cf Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 16:28:50 -0400 Subject: [PATCH 18/51] fixing assignment again --- r0b3bot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index 61b0d87..9b26f53 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1199,7 +1199,7 @@ async def MMR_Monitor(): print(f">> Status of '{handle}' has changed, notifying subscribed channels") if status > mmrsublist[handle]['AvgRank']: - mmrsublist[handle]['AvgRank'] = status['AvgRank'] + mmrsublist[handle]['AvgRank'] = str(status['AvgRank']) for channel in mmrsublist[handle]['channels']: ctx = bot.get_channel(channel) print(f">> Alerting {ctx} that '{handle}'s Average Rank has Increased!") @@ -1207,7 +1207,7 @@ async def MMR_Monitor(): await ctx.send(embed=embed) elif status < mmrsublist[handle]['AvgRank']: - mmrsublist[handle]['AvgRank'] = status['AvgRank'] + mmrsublist[handle]['AvgRank'] = str(status['AvgRank']) for channel in mmrsublist[handle]['channels']: ctx = bot.get_channel(channel) print(f">> Alerting {ctx} that '{handle}'s Average Rank has Decreased!") -- 2.39.5 From 1785162cea9e6c91fde3266d277229b0e7f566ce Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 16:30:15 -0400 Subject: [PATCH 19/51] fixing assignment again... hopefully for the last time --- r0b3bot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index 9b26f53..8ccbc38 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1199,7 +1199,7 @@ async def MMR_Monitor(): print(f">> Status of '{handle}' has changed, notifying subscribed channels") if status > mmrsublist[handle]['AvgRank']: - mmrsublist[handle]['AvgRank'] = str(status['AvgRank']) + mmrsublist[handle]['AvgRank'] = status for channel in mmrsublist[handle]['channels']: ctx = bot.get_channel(channel) print(f">> Alerting {ctx} that '{handle}'s Average Rank has Increased!") @@ -1207,7 +1207,7 @@ async def MMR_Monitor(): await ctx.send(embed=embed) elif status < mmrsublist[handle]['AvgRank']: - mmrsublist[handle]['AvgRank'] = str(status['AvgRank']) + mmrsublist[handle]['AvgRank'] = status for channel in mmrsublist[handle]['channels']: ctx = bot.get_channel(channel) print(f">> Alerting {ctx} that '{handle}'s Average Rank has Decreased!") -- 2.39.5 From 8f41991a3d35d7b4eee0b89843f8c0d4691e2a2d Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 16:31:09 -0400 Subject: [PATCH 20/51] fixing assignment again... hopefully for the last time, again --- r0b3bot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index 8ccbc38..9273a36 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1203,7 +1203,7 @@ async def MMR_Monitor(): for channel in mmrsublist[handle]['channels']: ctx = bot.get_channel(channel) print(f">> Alerting {ctx} that '{handle}'s Average Rank has Increased!") - embed = discord.Embed(title=f"MMR Alert", description=f"{handle}'s rank is {status['AvgRank']}", color=0x00ff40) + embed = discord.Embed(title=f"MMR Alert", description=f"{handle}'s rank is {status}", color=0x00ff40) await ctx.send(embed=embed) elif status < mmrsublist[handle]['AvgRank']: @@ -1211,7 +1211,7 @@ async def MMR_Monitor(): for channel in mmrsublist[handle]['channels']: ctx = bot.get_channel(channel) print(f">> Alerting {ctx} that '{handle}'s Average Rank has Decreased!") - embed = discord.Embed(title=f"MMR Alert", description=f"{handle}'s rank is {status['AvgRank']}", color=0xff2200) + embed = discord.Embed(title=f"MMR Alert", description=f"{handle}'s rank is {status}", color=0xff2200) await ctx.send(embed=embed) else: -- 2.39.5 From 3f9a976742424a1371f8d828ec86480fba0145da Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 17:17:49 -0400 Subject: [PATCH 21/51] clarifying alert text --- r0b3bot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index 9273a36..e0df879 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1203,7 +1203,7 @@ async def MMR_Monitor(): for channel in mmrsublist[handle]['channels']: ctx = bot.get_channel(channel) print(f">> Alerting {ctx} that '{handle}'s Average Rank has Increased!") - embed = discord.Embed(title=f"MMR Alert", description=f"{handle}'s rank is {status}", color=0x00ff40) + embed = discord.Embed(title=f"MMR Alert", description=f"{handle}'s rank increased to {status}!", color=0x00ff40) await ctx.send(embed=embed) elif status < mmrsublist[handle]['AvgRank']: @@ -1211,7 +1211,7 @@ async def MMR_Monitor(): for channel in mmrsublist[handle]['channels']: ctx = bot.get_channel(channel) print(f">> Alerting {ctx} that '{handle}'s Average Rank has Decreased!") - embed = discord.Embed(title=f"MMR Alert", description=f"{handle}'s rank is {status}", color=0xff2200) + embed = discord.Embed(title=f"MMR Alert", description=f"{handle}'s rank decreased to {status}!", color=0xff2200) await ctx.send(embed=embed) else: -- 2.39.5 From 25abfb2a59da9e1d84605158ad8caeeecb5ac2b4 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 18:23:30 -0400 Subject: [PATCH 22/51] updating info command --- r0b3bot.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index e0df879..0e1b0e4 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1243,7 +1243,13 @@ async def MMR_Monitor(): @bot.command() async def help(ctx): - embed = discord.Embed(title="R0b3BOT", description="List of commands are:", color=0xeee657) + embed = discord.Embed(title='R0b3BOT Core & Debug Commands:', description="Core commands for info and debug", color=0xeee657) + embed.add_field(name=f"{BOT_COMMAND_PREFIX}info", value="Gives a little info about the bot", inline=False) + embed.add_field(name=f"{BOT_COMMAND_PREFIX}help", value="Gives this message", inline=False) + embed.add_field(name=f"{BOT_COMMAND_PREFIX}last_error", value="Will display the real error message the bot has last encountered for additional debugging info") + await ctx.send(embed=embed) + + embed = discord.Embed(title="R0b3BOT Sound Commands", description="To play a sound in a chat channel, use one of the following:", color=0xeee657) embed.add_field(name=f"{BOT_COMMAND_PREFIX}printstat", value="Uploads a snapshot of Rich's 3D printer and current stats", inline=False) embed.add_field(name=f"{BOT_COMMAND_PREFIX}explain", value="Displays Dalek EXPLAIN gif", inline=False) embed.add_field(name=f"{BOT_COMMAND_PREFIX}holyshit", value="Displays Marty McFly HOLY SHIT gif", inline=False) @@ -1260,14 +1266,19 @@ async def help(ctx): embed.add_field(name=f"{BOT_COMMAND_PREFIX}heavy @member", value="Plays 'Poppy ooo heavy'") embed.add_field(name=f"{BOT_COMMAND_PREFIX}iran @member", value="Plays Trump 'I Ran'") embed.add_field(name=f"{BOT_COMMAND_PREFIX}big @member", value="Plays 'Wiz Khalifa clip'") - embed.add_field(name=f"{BOT_COMMAND_PREFIX}info", value="Gives a little info about the bot", inline=False) - embed.add_field(name=f"{BOT_COMMAND_PREFIX}help", value="Gives this message", inline=False) - embed.add_field(name=f"{BOT_COMMAND_PREFIX}last_error", value="Will display the real error message the bot has last encountered for additional debugging info") + await ctx.send(embed=embed) + + embed = discord.Embed(title="A note about sound clips:", description="Sound clips are only played in voice channels. If a user is not specified when calling the command, the sound will played in the channel of that issuing user is currently joined to. When a username is specified, the bot will play the sound in the channel that user is currently in.") + await ctx.send(embed=embed) + + embed = discord.Embed(title="StatPing Service Monitor Commands", description="Commands for managing the StatPing Service Monitor", color=0xeee657) embed.add_field(name=f"{BOT_COMMAND_PREFIX}spstatus servicename", value="Retrieves status of service from StatPing") embed.add_field(name=f"{BOT_COMMAND_PREFIX}spsub service", value="Allows user to subscribe to service status change alerts for the channel. Can replace with -list and -del:service to manage alerts. NOTICE:Replace spaces in service names w/ '_'!") await ctx.send(embed=embed) - embed = discord.Embed(title="A note about sound clips:", description="Sound clips are only played in voice channels. If a user is not specified when calling the command, the sound will played in the channel of that issuing user is currently joined to. When a username is specified, the bot will play the sound in the channel that user is currently in.") + embed = discord.Embed(title="MMR Monitor Commands", description="Commands for managing the MMR Checker", color=0xeee657) + embed.add_field(name=f"{BOT_COMMAND_PREFIX}mmrstatus handle", value="Queries the MMR API for the handle specified and returns the current Ranked Average") + embed.add_field(name=f"{BOT_COMMAND_PREFIX}mmrsub handle", value="Subscribe to receive alerts of ranked average changes for the specified handle") await ctx.send(embed=embed) # Function to run shell command and return stdout or sterr -- 2.39.5 From 8d91336b43f6d50b31c32899fc3526472e10d65d Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 18:31:41 -0400 Subject: [PATCH 23/51] Added mmrstatus command --- r0b3bot.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/r0b3bot.py b/r0b3bot.py index 0e1b0e4..68b4ce3 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -937,6 +937,24 @@ async def get_stp_status(service): # # Begin functions for MMR sub/alerts # + +@bot.command() +async def mmrstatus(ctx, handle = "NONE"): + + if handle != "NONE": + + #await get_stp_status(ctx, service.lower()) + result = await get_mmr_status(handle) + + if result == "handle not found": + await ctx.send(f"'{service}' was not found") + else: + await ctx.send(f"'{handle}'s Ranked Average is: {result}") + + else: + await ctx.send("Please speficy a service name to query.") + + @bot.command() async def mmrsub(ctx, handle = "NONE"): -- 2.39.5 From 403aa9a362d58774e28e6328cc65300f03ea4d2a Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 19:00:42 -0400 Subject: [PATCH 24/51] check if handle was actually found --- r0b3bot.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index 68b4ce3..f989368 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -954,7 +954,6 @@ async def mmrstatus(ctx, handle = "NONE"): else: await ctx.send("Please speficy a service name to query.") - @bot.command() async def mmrsub(ctx, handle = "NONE"): @@ -1173,12 +1172,16 @@ async def mmr_monitor(sublist): async def get_mmr_status(mmrhandle): - # Get StatPing status via REST API + # Get MMR status status via API #need to replace spaces with %20 before just inserting into URL mmrhandle.replace(" ", "%20") mmrURL = ''.join(mmrURLBASE) + mmrhandle response = requests.get(mmrURL, headers=mmrHEADERS) mmr_stats = json.loads(response.text) + + if int(response.find("No MMR data")) < 0: + mmr_stats = "handle not found" + return mmr_stats['ranked']['avg'] -- 2.39.5 From fcb0051c874428af78cf701f614fe39de06ca819 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 19:03:15 -0400 Subject: [PATCH 25/51] fixing --- r0b3bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r0b3bot.py b/r0b3bot.py index f989368..78ddff0 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1179,7 +1179,7 @@ async def get_mmr_status(mmrhandle): response = requests.get(mmrURL, headers=mmrHEADERS) mmr_stats = json.loads(response.text) - if int(response.find("No MMR data")) < 0: + if int(str.response.find("No MMR data")) < 0: mmr_stats = "handle not found" -- 2.39.5 From 6823161897af0faa55d420b378e3b1d24ec97634 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 19:03:52 -0400 Subject: [PATCH 26/51] fixing... --- r0b3bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r0b3bot.py b/r0b3bot.py index 78ddff0..1b4f056 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1179,7 +1179,7 @@ async def get_mmr_status(mmrhandle): response = requests.get(mmrURL, headers=mmrHEADERS) mmr_stats = json.loads(response.text) - if int(str.response.find("No MMR data")) < 0: + if int(str(response).find("No MMR data")) < 0: mmr_stats = "handle not found" -- 2.39.5 From ba014f4c98c671464c9f2f79e477e9ed8643d1d4 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 19:05:27 -0400 Subject: [PATCH 27/51] fixing... --- r0b3bot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/r0b3bot.py b/r0b3bot.py index 1b4f056..9ff87ac 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1181,6 +1181,7 @@ async def get_mmr_status(mmrhandle): if int(str(response).find("No MMR data")) < 0: mmr_stats = "handle not found" + return mmr_stats return mmr_stats['ranked']['avg'] -- 2.39.5 From dfa82dbe969107cfe1f78513e4db7bfe4de57624 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 19:06:59 -0400 Subject: [PATCH 28/51] correcting variable being used --- r0b3bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r0b3bot.py b/r0b3bot.py index 9ff87ac..d4fa8b1 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -947,7 +947,7 @@ async def mmrstatus(ctx, handle = "NONE"): result = await get_mmr_status(handle) if result == "handle not found": - await ctx.send(f"'{service}' was not found") + await ctx.send(f"'{handle}' was not found") else: await ctx.send(f"'{handle}'s Ranked Average is: {result}") -- 2.39.5 From 0077f1a80b354d3c438048d03bd20ce49a1a9abe Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 19:09:34 -0400 Subject: [PATCH 29/51] troubleshooting response check --- r0b3bot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/r0b3bot.py b/r0b3bot.py index d4fa8b1..b3299a3 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1179,7 +1179,8 @@ async def get_mmr_status(mmrhandle): response = requests.get(mmrURL, headers=mmrHEADERS) mmr_stats = json.loads(response.text) - if int(str(response).find("No MMR data")) < 0: + print(f"{str(response).find("No MMR data")}") + if str(response).find("No MMR data") < 0: mmr_stats = "handle not found" return mmr_stats -- 2.39.5 From b6d5ce6836776a9da0c593db586cd8971d8acf42 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 19:11:16 -0400 Subject: [PATCH 30/51] troubleshooting response check: fixing syntax --- r0b3bot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index b3299a3..b0303b8 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1179,8 +1179,9 @@ async def get_mmr_status(mmrhandle): response = requests.get(mmrURL, headers=mmrHEADERS) mmr_stats = json.loads(response.text) - print(f"{str(response).find("No MMR data")}") - if str(response).find("No MMR data") < 0: + checked = str(response).find("No MMR data") + print(f"{checked}") + if checked < 0: mmr_stats = "handle not found" return mmr_stats -- 2.39.5 From 5ada6cfb3681965a7b310a1f69c379ffa8ec26b0 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 19:13:08 -0400 Subject: [PATCH 31/51] troubleshooting response check: welp, had that backwards --- r0b3bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r0b3bot.py b/r0b3bot.py index b0303b8..6189e98 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1181,7 +1181,7 @@ async def get_mmr_status(mmrhandle): checked = str(response).find("No MMR data") print(f"{checked}") - if checked < 0: + if checked > 0: mmr_stats = "handle not found" return mmr_stats -- 2.39.5 From 667126c916f854cf3c0f7cf6a9d94d80dca2cdd5 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 19:18:31 -0400 Subject: [PATCH 32/51] dunno --- r0b3bot.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index 6189e98..f07b0a0 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -941,6 +941,8 @@ async def get_stp_status(service): @bot.command() async def mmrstatus(ctx, handle = "NONE"): + print(f">> {BOT_COMMAND_PREFIX}mmrstatus was called for {handle}") + if handle != "NONE": #await get_stp_status(ctx, service.lower()) @@ -1179,9 +1181,9 @@ async def get_mmr_status(mmrhandle): response = requests.get(mmrURL, headers=mmrHEADERS) mmr_stats = json.loads(response.text) - checked = str(response).find("No MMR data") + checked = str(response).find("error") print(f"{checked}") - if checked > 0: + if checked == -1: mmr_stats = "handle not found" return mmr_stats -- 2.39.5 From 1e64e992dde1d1d9ac5ced3944cab8c15f8f621e Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 19:25:05 -0400 Subject: [PATCH 33/51] let's try it this way --- r0b3bot.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index f07b0a0..79174aa 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1181,13 +1181,9 @@ async def get_mmr_status(mmrhandle): response = requests.get(mmrURL, headers=mmrHEADERS) mmr_stats = json.loads(response.text) - checked = str(response).find("error") - print(f"{checked}") - if checked == -1: - mmr_stats = "handle not found" - return mmr_stats + if "error" in mmr_status: + return "handle not found" - return mmr_stats['ranked']['avg'] -- 2.39.5 From 5e1164d98cd0d3f6f8ea95a68d5f986ef254632e Mon Sep 17 00:00:00 2001 From: Rich O Date: Sat, 20 Mar 2021 19:25:50 -0400 Subject: [PATCH 34/51] typo --- r0b3bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r0b3bot.py b/r0b3bot.py index 79174aa..345ea45 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1181,7 +1181,7 @@ async def get_mmr_status(mmrhandle): response = requests.get(mmrURL, headers=mmrHEADERS) mmr_stats = json.loads(response.text) - if "error" in mmr_status: + if "error" in mmr_stats: return "handle not found" return mmr_stats['ranked']['avg'] -- 2.39.5 From 37e9512d82a9d81f6f5a1439b7437827e9d0fea9 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sun, 21 Mar 2021 07:44:27 -0400 Subject: [PATCH 35/51] troubleshooting -list command --- r0b3bot.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index 345ea45..8db4e0a 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -603,11 +603,7 @@ bot.remove_command('help') @bot.command() async def spstatus(ctx, service = "NONE"): -#async def spalert(ctx, cmd = "NONE", arg = "NONE"): - # if cmd != "NONE": - # if cmd == "add": - # spalert += if service != "NONE": #await get_stp_status(ctx, service.lower()) @@ -963,7 +959,7 @@ async def mmrsub(ctx, handle = "NONE"): # Structure of spsublist nested dictionary # spsublist[service name][list of channel ids][a state value] # dict = {'Handle': {'AvgRank' : 'value', 'channels' : ['1232', '43234']} - # 'Space Eingineers' : {'state' : online', 'channels' : ['2343', '54563']}} + # 'twtv iddosu2x' : {'AvgRank' : '1082', 'channels' : ['2343', '54563']}} # mmrcurrentsub_request = [] # list of elements detailing the current sub request datestring = datetime.now() @@ -992,10 +988,11 @@ async def mmrsub(ctx, handle = "NONE"): mmrsublist = pickle.loads(pickled_mmrsublist) for handle in mmrsublist.keys(): - + print{f"current handle: {handle}") for channel in mmrsublist[handle]['channels']: + print(f">> {channel}") if channel == ctx.channel.id: - mmrsublist += f"'{handle}' " + mmrsublist += f"'{handle}'" await ctx.send(f"This channel is subscribed to: {mmrsublist}") -- 2.39.5 From d961698d404d348e26057f1ab7e9fd506c52559f Mon Sep 17 00:00:00 2001 From: Rich O Date: Sun, 21 Mar 2021 07:45:15 -0400 Subject: [PATCH 36/51] typo --- r0b3bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r0b3bot.py b/r0b3bot.py index 8db4e0a..b1de05a 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -988,7 +988,7 @@ async def mmrsub(ctx, handle = "NONE"): mmrsublist = pickle.loads(pickled_mmrsublist) for handle in mmrsublist.keys(): - print{f"current handle: {handle}") + print(f"current handle: {handle}") for channel in mmrsublist[handle]['channels']: print(f">> {channel}") if channel == ctx.channel.id: -- 2.39.5 From 3b5ecf4b6b29f3dd9e5fc947c41ae14cb0ab2458 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sun, 21 Mar 2021 07:46:56 -0400 Subject: [PATCH 37/51] more debug --- r0b3bot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/r0b3bot.py b/r0b3bot.py index b1de05a..9a5f1f9 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -992,6 +992,7 @@ async def mmrsub(ctx, handle = "NONE"): for channel in mmrsublist[handle]['channels']: print(f">> {channel}") if channel == ctx.channel.id: + print(f">>>> {channel} == {ctx.channel.id}") mmrsublist += f"'{handle}'" await ctx.send(f"This channel is subscribed to: {mmrsublist}") -- 2.39.5 From 5767d2d606f4fc2bcf119d683bed4d54ad879d60 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sun, 21 Mar 2021 07:53:06 -0400 Subject: [PATCH 38/51] was using wrong varibale --- r0b3bot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index 9a5f1f9..0d4c7a0 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -985,15 +985,15 @@ async def mmrsub(ctx, handle = "NONE"): mmrsublist = '' async with aiof.open('mmrsublist.dat', 'rb') as datafile: pickled_mmrsublist = await datafile.read() - mmrsublist = pickle.loads(pickled_mmrsublist) + sublist = pickle.loads(pickled_mmrsublist) - for handle in mmrsublist.keys(): + for handle in sublist.keys(): print(f"current handle: {handle}") for channel in mmrsublist[handle]['channels']: print(f">> {channel}") if channel == ctx.channel.id: print(f">>>> {channel} == {ctx.channel.id}") - mmrsublist += f"'{handle}'" + mmrsublist += f"'{handle}' " await ctx.send(f"This channel is subscribed to: {mmrsublist}") -- 2.39.5 From 9421b22cff6cb2bac0e492938d3e96859206a4c9 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sun, 21 Mar 2021 07:54:10 -0400 Subject: [PATCH 39/51] was using wrong varibale... missed ong --- r0b3bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r0b3bot.py b/r0b3bot.py index 0d4c7a0..bb0d540 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -989,7 +989,7 @@ async def mmrsub(ctx, handle = "NONE"): for handle in sublist.keys(): print(f"current handle: {handle}") - for channel in mmrsublist[handle]['channels']: + for channel in sublist[handle]['channels']: print(f">> {channel}") if channel == ctx.channel.id: print(f">>>> {channel} == {ctx.channel.id}") -- 2.39.5 From e9a2165f78e70b657df9ffe03aca749203424bf3 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sun, 21 Mar 2021 11:41:45 -0400 Subject: [PATCH 40/51] found some issues --- r0b3bot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index bb0d540..089fe85 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1029,7 +1029,7 @@ async def mmrsub(ctx, handle = "NONE"): # Marking channel as found found_channel = True # Get the proper name of the service - handle_toremove = service + handle_toremove = handle #Remove the current users channel from this service mmrsublist[handle]['channels'].remove(ctx.channel.id) # Break since we're done. @@ -1051,7 +1051,7 @@ async def mmrsub(ctx, handle = "NONE"): await ctx.send(f"This channel is not subscribed to alerts for '{handle_toremove}''") # If the service exists, proceed with adding it to the list. - elif handle_state != "service not found": + elif handle_state != "handle not found": print(f">> '{handle}' is a valid Hanlde on Whatismymmr.com.") print(f">> Checking if it has already been subscribed to") @@ -1095,7 +1095,7 @@ async def mmrsub(ctx, handle = "NONE"): # Append the current channel id to the list for this service print(f">> Adding handle '{mmrcurrentsub_request[1]}' to {ctx.channel.id}") await ctx.send(f"{handle} has been added to monitored handles for this channel") - mmrsublist[service]['channels'].append(mmrcurrentsub_request[0]) + mmrsublist[handle]['channels'].append(mmrcurrentsub_request[0]) break if not found_handle: -- 2.39.5 From 86e79448370c5cb2f8f3c46079f3a3d7c39eb244 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sun, 21 Mar 2021 12:05:31 -0400 Subject: [PATCH 41/51] editing output for clarity --- r0b3bot.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index 089fe85..602fb41 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1077,9 +1077,9 @@ async def mmrsub(ctx, handle = "NONE"): found_handle = False found_channel = False for handle in mmrsublist.keys(): - print(f">> Does {handle.lower()} == {mmrcurrentsub_request[1].lower()}") + print(f">> Does {handle} == {mmrcurrentsub_request[1]}") - if handle.lower() == mmrcurrentsub_request[1].lower(): + if handle == mmrcurrentsub_request[1]: found_handle = True # This service matched what the user is trying to subscribe to # Now we need to check if this is for the same channel @@ -1087,20 +1087,20 @@ async def mmrsub(ctx, handle = "NONE"): for channel in mmrsublist[handle]['channels']: if channel == mmrcurrentsub_request[0]: - print(f">> This channel is already subscribed to {handle}") + print(f">> Handle exists, channel ({mmrcurrentsub_request[0]}) is already subscribed to {handle}") await ctx.send(f"This channel is already subscribed to {handle} alerts") found_channel = True break if not found_channel: # Append the current channel id to the list for this service - print(f">> Adding handle '{mmrcurrentsub_request[1]}' to {ctx.channel.id}") + print(f">> Handle exists, channel not subbed, adding handle '{mmrcurrentsub_request[1]}' to {ctx.channel.id}") await ctx.send(f"{handle} has been added to monitored handles for this channel") mmrsublist[handle]['channels'].append(mmrcurrentsub_request[0]) break if not found_handle: # Append the current channel id to the list for this service - print(f">> Adding handle '{mmrcurrentsub_request[1]}' to {ctx.channel.id}") + print(f">> Handle does not exist, adding new entry for '{mmrcurrentsub_request[1]}' to {ctx.channel.id}") await ctx.send(f"{mmrcurrentsub_request[1]} has been added to monitored handle for this channel") #newsub = {} #newsub[currentsub_request[1]] = {'state' : 'online', 'channels' : [currentsub_request[0]]} -- 2.39.5 From 45d8d5702c4b0059ebf43c8b5f53c0e43951d047 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sun, 21 Mar 2021 12:11:24 -0400 Subject: [PATCH 42/51] found typo --- r0b3bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r0b3bot.py b/r0b3bot.py index 602fb41..d894661 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1071,7 +1071,7 @@ async def mmrsub(ctx, handle = "NONE"): # Read in mmrsublist async with aiof.open('mmrsublist.dat', 'rb') as datafile: pickled_mmrsublist = await datafile.read() - mmrspsublist = pickle.loads(pickled_mmrsublist) + mmrsublist = pickle.loads(pickled_mmrsublist) print(f">> Checking if handle is already in datafile") found_handle = False -- 2.39.5 From e00da208701940abb71f44d7d133475576e5d567 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sun, 21 Mar 2021 12:17:00 -0400 Subject: [PATCH 43/51] Cleaning up output text --- r0b3bot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index d894661..54d97a0 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1077,17 +1077,17 @@ async def mmrsub(ctx, handle = "NONE"): found_handle = False found_channel = False for handle in mmrsublist.keys(): - print(f">> Does {handle} == {mmrcurrentsub_request[1]}") + print(f">> Does '{handle}'' == '{mmrcurrentsub_request[1]}'?") if handle == mmrcurrentsub_request[1]: found_handle = True # This service matched what the user is trying to subscribe to # Now we need to check if this is for the same channel - print(f">> Found {handle} in data file, checking for channel") + print(f">> Yes, checking if channel {mmrcurrentsub_request[0]} is already subscribed") for channel in mmrsublist[handle]['channels']: if channel == mmrcurrentsub_request[0]: - print(f">> Handle exists, channel ({mmrcurrentsub_request[0]}) is already subscribed to {handle}") + print(f">> Channel ({mmrcurrentsub_request[0]}) is already subscribed to {handle}") await ctx.send(f"This channel is already subscribed to {handle} alerts") found_channel = True break -- 2.39.5 From a53cab8343a183d43fde61ae2f5dd1444ff70f06 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sun, 21 Mar 2021 12:24:03 -0400 Subject: [PATCH 44/51] working on mmrstatus --- r0b3bot.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/r0b3bot.py b/r0b3bot.py index 54d97a0..ba35d18 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -945,11 +945,14 @@ async def mmrstatus(ctx, handle = "NONE"): result = await get_mmr_status(handle) if result == "handle not found": + print(f">> {handle} was not found") await ctx.send(f"'{handle}' was not found") else: + print(f">> {handle} found!") await ctx.send(f"'{handle}'s Ranked Average is: {result}") else: + print(f">> User did not speficy handle") await ctx.send("Please speficy a service name to query.") @bot.command() -- 2.39.5 From 2cbaef99c086bad1f27f2780c3c7f0034442ed0e Mon Sep 17 00:00:00 2001 From: Rich O Date: Sun, 21 Mar 2021 12:26:25 -0400 Subject: [PATCH 45/51] working on mmrstatus --- r0b3bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r0b3bot.py b/r0b3bot.py index ba35d18..f072062 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -946,7 +946,7 @@ async def mmrstatus(ctx, handle = "NONE"): if result == "handle not found": print(f">> {handle} was not found") - await ctx.send(f"'{handle}' was not found") + await ctx.send(f"'{handle}' was not found. Try wrapping handle in double quotes") else: print(f">> {handle} found!") await ctx.send(f"'{handle}'s Ranked Average is: {result}") -- 2.39.5 From ad05b2f4276fe5d1348636aba5e9b92d97ba8de9 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sun, 21 Mar 2021 12:37:20 -0400 Subject: [PATCH 46/51] updating help command details --- r0b3bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r0b3bot.py b/r0b3bot.py index f072062..9853448 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1301,7 +1301,7 @@ async def help(ctx): embed = discord.Embed(title="MMR Monitor Commands", description="Commands for managing the MMR Checker", color=0xeee657) embed.add_field(name=f"{BOT_COMMAND_PREFIX}mmrstatus handle", value="Queries the MMR API for the handle specified and returns the current Ranked Average") - embed.add_field(name=f"{BOT_COMMAND_PREFIX}mmrsub handle", value="Subscribe to receive alerts of ranked average changes for the specified handle") + embed.add_field(name=f"{BOT_COMMAND_PREFIX}mmrsub handle", value="Subscribe to receive alerts of ranked average changes for the specified handle. Can run command with just '-list' to list handle the current channel is subbed to. Use -del:service to unsub from a handle. NOTICE:Replace spaces in service names w/ '_'!"") await ctx.send(embed=embed) # Function to run shell command and return stdout or sterr -- 2.39.5 From 15d0a01dcb717660e7b363fca4b94b8c65213589 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sun, 21 Mar 2021 12:37:56 -0400 Subject: [PATCH 47/51] typo --- r0b3bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r0b3bot.py b/r0b3bot.py index 9853448..8b34a06 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -1301,7 +1301,7 @@ async def help(ctx): embed = discord.Embed(title="MMR Monitor Commands", description="Commands for managing the MMR Checker", color=0xeee657) embed.add_field(name=f"{BOT_COMMAND_PREFIX}mmrstatus handle", value="Queries the MMR API for the handle specified and returns the current Ranked Average") - embed.add_field(name=f"{BOT_COMMAND_PREFIX}mmrsub handle", value="Subscribe to receive alerts of ranked average changes for the specified handle. Can run command with just '-list' to list handle the current channel is subbed to. Use -del:service to unsub from a handle. NOTICE:Replace spaces in service names w/ '_'!"") + embed.add_field(name=f"{BOT_COMMAND_PREFIX}mmrsub handle", value="Subscribe to receive alerts of ranked average changes for the specified handle. Can run command with just '-list' to list handle the current channel is subbed to. Use -del:service to unsub from a handle. NOTICE:Replace spaces in service names w/ '_'!") await ctx.send(embed=embed) # Function to run shell command and return stdout or sterr -- 2.39.5 From 8bb132be24743a8a490c9762fcb86125a7ffe93e Mon Sep 17 00:00:00 2001 From: Rich O Date: Sun, 21 Mar 2021 12:44:49 -0400 Subject: [PATCH 48/51] Organizing --- r0b3bot.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index 8b34a06..be66006 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -2,45 +2,47 @@ import discord from discord.ext import commands +from discord import FFmpegPCMAudio +from discord.utils import get +from discord.voice_client import VoiceClient +from datetime import datetime import urllib.request import random import os import sys import octoapi import time -from datetime import datetime import configparser import json -from discord import FFmpegPCMAudio -from discord.utils import get -from discord.voice_client import VoiceClient import requests import asyncio -#from aiofile import AIOFile import aiofiles as aiof import pickle - #Record the time the bot started start_time = time.time() config = configparser.RawConfigParser() configFilePath = r'bot_config.conf' -# Last error message variable used by $last_error command to display in discord -global last_error -last_error = "No errors have been recorded." - try: config.read(configFilePath) except: print("Error loading config! Please check config file 'bot-config.conf'") +# Last error message variable used by $last_error command to display in discord +global last_error +last_error = "No errors have been recorded." + # -# Read in bot configurations +# Assign bot config from setting in config file # -# Setup HomeAssistant URL and Headers +# Assign Bot core settings +DISCORD_AUTH_TOKEN = config.get('bot-config', 'discord_auth_token') +BOT_COMMAND_PREFIX = config.get('bot-config', 'bot_command_prefix') + +# 3D Printer Setup - HomeAssistant URL and Headers & OctoPrint HASS_TOKEN = config.get('bot-config', 'hass_token') HASS_URL = config.get('bot-config', 'hass_url') HASS_LIGHT = config.get('bot-config', 'hass_light') @@ -49,10 +51,9 @@ hassHEADERS = { 'Authorization': f"Bearer {HASS_TOKEN}", 'content-type': 'application/json', } - OCTOPRINT_IP_ADDRESS = config.get('bot-config', 'octoprint_ip_address') -DISCORD_AUTH_TOKEN = config.get('bot-config', 'discord_auth_token') -BOT_COMMAND_PREFIX = config.get('bot-config', 'bot_command_prefix') + +# StatPing Monitor Settings statping_enable = config.get('bot-config', 'statping_enable') STATPING_URL = config.get('bot-config', 'statping_url') STATPING_API_KEY = config.get('bot-config', 'statping_api_key') @@ -62,6 +63,7 @@ statpingHEADERS = { 'content-type': 'application/json', } +#MMR Checker Settings mmr_checker_enable = config.get('bot-config', 'mmr_checker_enable') mmr_checker_interval = config.get('bot-config', 'mmr_checker_interval') mmrURLBASE = config.get('bot-config', 'mmr_api_url') @@ -70,7 +72,7 @@ mmrHEADERS = { 'content-type': 'application/json', } -# Configure bot +# Configure bot bot = commands.Bot(command_prefix=BOT_COMMAND_PREFIX, description='A derpy derp of a bot.') # Printing configuration details to console -- 2.39.5 From b1d1a7b1cc4252b19081df62246ca3afcd0ea05e Mon Sep 17 00:00:00 2001 From: Rich O Date: Sun, 21 Mar 2021 13:07:25 -0400 Subject: [PATCH 49/51] Cleanup of code --- r0b3bot.py | 88 ++---------------------------------------------------- 1 file changed, 2 insertions(+), 86 deletions(-) diff --git a/r0b3bot.py b/r0b3bot.py index be66006..273b235 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -566,7 +566,6 @@ async def updateStatus(): activity = discord.Activity(name="your commands",type=discord.ActivityType.listening) await bot.change_presence(activity=activity) - @bot.command() async def info(ctx): embed = discord.Embed(title="R0b3BOT", description="Derpy Derp of a Bot :P", color=0xeee657) @@ -601,8 +600,6 @@ async def info(ctx): embed.add_field(name="Source Code:", value="[R0b3Bot on Gitlab](https://gitlab.rickelobe.com/Bots/r0b3BOT)", inline=False) await ctx.send(embed=embed) -bot.remove_command('help') - @bot.command() async def spstatus(ctx, service = "NONE"): @@ -623,8 +620,6 @@ async def spstatus(ctx, service = "NONE"): else: await ctx.send("Please speficy a service name to query.") - - @bot.command() async def spsub(ctx, service = "NONE"): @@ -873,45 +868,6 @@ async def StatPing_Monitor(): print(">> spsublist.dat does not exist, nothing to do.") await asyncio.sleep(60) - - -async def sp_monitor(sublist): - - # Checks the services listed in spsublist for status change - # Sublist is a list of 3 items: - # - ctx (used to send alert to channel) - # - service (the name of the service to check) - # - status string (last status of the service, either 'online' or 'offline') - - ctx = sublist[0] - - - while True: - - status = await get_stp_status(spsublist[1]) - if status['online'] and spsublist[2] == "online": - # nothing has changed, no alert needed - await asyncio.sleep(1) - elif not status['online'] and spsublist[2] == "offline": - # again, nothing has changed no alert needed - await asyncio.sleep(1) - else: - print(f"Status of {status['name']}' has changed") - if status['online']: - embed = discord.Embed(title=f"{status['name']} Service Alert", description=f"{spsublist[1]} is Online!", color=0x00ff40) - await ctx.send(embed=embed) - #await ctx.send(f"{spsublist[1]} is Online!") - spsublist[2] = "online" - elif not status['online']: - embed = discord.Embed(title=f"{status['name']} Service Alert", description=f"{spsublist[1]} is Offline!", color=0xff2200) - await ctx.send(embed=embed) - #await ctx.send(f"{spsublist[1]} is Offline!") - spsublist[2] = "offline" - else: - embed = discord.Embed(title=f"{status['name']} Service Alert", description=f"{spsublist[1]} is in an unknown state!", color=0xffff00) - await ctx.send(embed=embed) - #await ctx.send(f"Unknown state for service {spsublist[1]}") - await asyncio.sleep(60) async def get_stp_status(service): @@ -1136,45 +1092,6 @@ async def mmrsub(ctx, handle = "NONE"): print(f">> '{handle}' does not exist, cancelling subscription") await ctx.send(f"{handle} was not found") -async def mmr_monitor(sublist): - - # Checks the services listed in spsublist for status change - # Sublist is a list of 3 items: - # - ctx (used to send alert to channel) - # - service (the name of the service to check) - # - status string (last status of the service, either 'online' or 'offline') - - ctx = sublist[0] - - - while True: - - status = await get_stp_status(spsublist[1]) - if status['online'] and spsublist[2] == "online": - # nothing has changed, no alert needed - await asyncio.sleep(1) - elif not status['online'] and spsublist[2] == "offline": - # again, nothing has changed no alert needed - await asyncio.sleep(1) - else: - print(f"Status of {status['name']}' has changed") - if status['online']: - embed = discord.Embed(title=f"{status['name']} Service Alert", description=f"{spsublist[1]} is Online!", color=0x00ff40) - await ctx.send(embed=embed) - #await ctx.send(f"{spsublist[1]} is Online!") - spsublist[2] = "online" - elif not status['online']: - embed = discord.Embed(title=f"{status['name']} Service Alert", description=f"{spsublist[1]} is Offline!", color=0xff2200) - await ctx.send(embed=embed) - #await ctx.send(f"{spsublist[1]} is Offline!") - spsublist[2] = "offline" - else: - embed = discord.Embed(title=f"{status['name']} Service Alert", description=f"{spsublist[1]} is in an unknown state!", color=0xffff00) - await ctx.send(embed=embed) - #await ctx.send(f"Unknown state for service {spsublist[1]}") - #Sleep for 3 hours - await asyncio.sleep(10800) - async def get_mmr_status(mmrhandle): # Get MMR status status via API @@ -1189,7 +1106,6 @@ async def get_mmr_status(mmrhandle): return mmr_stats['ranked']['avg'] - async def MMR_Monitor(): # reads in "mmrsublist.dat" every 3 hours then iterates @@ -1228,7 +1144,7 @@ async def MMR_Monitor(): for channel in mmrsublist[handle]['channels']: ctx = bot.get_channel(channel) print(f">> Alerting {ctx} that '{handle}'s Average Rank has Increased!") - embed = discord.Embed(title=f"MMR Alert", description=f"{handle}'s rank increased to {status}!", color=0x00ff40) + embed = discord.Embed(title=f"MMR Alert", description=f"{handle}'s ranked average increased to {status}!", color=0x00ff40) await ctx.send(embed=embed) elif status < mmrsublist[handle]['AvgRank']: @@ -1236,7 +1152,7 @@ async def MMR_Monitor(): for channel in mmrsublist[handle]['channels']: ctx = bot.get_channel(channel) print(f">> Alerting {ctx} that '{handle}'s Average Rank has Decreased!") - embed = discord.Embed(title=f"MMR Alert", description=f"{handle}'s rank decreased to {status}!", color=0xff2200) + embed = discord.Embed(title=f"MMR Alert", description=f"{handle}'s ranked average decreased to {status}!", color=0xff2200) await ctx.send(embed=embed) else: -- 2.39.5 From 41b1c73ff3bbfda12cff3cd107cf97cc3a67a6a7 Mon Sep 17 00:00:00 2001 From: Rich O Date: Sun, 21 Mar 2021 13:10:16 -0400 Subject: [PATCH 50/51] adding back bot.remove_command entry --- r0b3bot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/r0b3bot.py b/r0b3bot.py index 273b235..612ffb8 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -74,6 +74,7 @@ mmrHEADERS = { # Configure bot bot = commands.Bot(command_prefix=BOT_COMMAND_PREFIX, description='A derpy derp of a bot.') +bot.remove_command('help') # Printing configuration details to console print("=== 3D Printer Status config ===") -- 2.39.5 From c528e0f6380b8a4f6c1e54dc1641b35716b7bacb Mon Sep 17 00:00:00 2001 From: Rich O Date: Sun, 21 Mar 2021 17:19:27 +0000 Subject: [PATCH 51/51] Added new feature --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index aadc5a8..bf2b36b 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ This is R0b3's Discord Bot. It's creation was basically a challenge posed a cow * Query serivces states on StatPing using the `$spstatus` * Use `$spsub` to "Subscribe" to service change alerts for StatPing services. Subscribed alerts are persistent and are not lost on bot restart.
![Example service alert](images/Service_alert.png) +* Use `$mmrsub` to "Subscribe" to a League of Legends handle's Ranked Average. As with the StatPing feature, the subscriptions are persistent. * Play a selection of sound clips to voice channel members using the various commands (`$torololo`, `$oops`, `$promoted`, etc) # Commands @@ -24,4 +25,4 @@ This is R0b3's Discord Bot. It's creation was basically a challenge posed a cow 1. Create a Discord Bot via Developer tools
2. Enter configuration parameters in bot_config.conf.example
3. Enter OctoPrint config parameters in octoapi.conf.example
-4. Rename *.example files as *.conf
\ No newline at end of file +4. Rename *.example files as *.conf and setup your config
-- 2.39.5