def parseArgs(day): semester = int(config.get("semester")) year = int(config.get("year")) years_counter = int(config.get("years")) # Check if a schedule or a day was called if len(day) == 0: day = [] else: # Only either of them was passed if len(day) == 1: # Called a schedule if day[0].isdigit(): if 0 < int(day[0]) < years_counter + 1: year = int(day[0]) day = [] else: return [False, "Dit is geen geldige jaargang."] # elif: calling a weekday is automatically handled below, # so checking is obsolete else: # TODO check other direction (di 1) in else # Both were passed if day[0].isdigit(): if 0 < int(day[0]) < years_counter + 1: year = int(day[0]) # day = [] else: return [False, "Dit is geen geldige jaargang."] # Cut the schedule from the string day = day[1:] day = getWeekDay(None if len(day) == 0 else day)[1] dayDatetime = findDate(timeFormatters.weekdayToInt(day)) return [True, day, dayDatetime, semester, year]
async def matches(self, ctx, *args): args = list(args) if not args: args = [str(config.get("jpl_day"))] if all(letter.isdigit() for letter in args[0]): current_day = requests.get( "https://api.sporza.be/web/soccer/matchdays/161733/{}".format( args[0])).json() current_day = current_day["groupedMatches"][0]["matches"] # Create dictionaries for every match matches_formatted = {} for i, match in enumerate(current_day): matchDic = { "home": match["homeTeam"]["name"], "away": match["awayTeam"]["name"] } # Add date matchDate = datetime.datetime.strptime( match["startDateTime"].split("+")[0], "%Y-%m-%dT%H:%M:%S.%f") matchDic["date"] = matchDate.strftime("%d/%m") matchDic["day"] = self.get_weekday(matchDate.weekday()) # TODO check back when there's active games (to find the key in the dict) & add the current time if not over # Add scores if match[ "status"] == "END": # Status != [not_yet_started] whatever it is matchDic["score"] = "{} - {}".format( match["homeScore"], match["awayScore"]) else: # If there's no score, show when the match starts matchDic["score"] = "{}:{}".format( ("" if len(str(matchDate.hour)) == 2 else "0") + str(matchDate.hour), # Leading Zero ("" if len(str(matchDate.minute)) == 2 else "0") + str(matchDate.minute)) # Leading Zero matches_formatted[i] = matchDic # Put every formatted version of the matches in a list matchList = list([ self.format_match(matches_formatted[match]) for match in matches_formatted ]) await ctx.send( "```Jupiler Pro League - Speeldag {}\n\n{}```".format( args[0], tabulate.tabulate(matchList, headers=[ "Dag", "Datum", "Thuis", "Stand", "Uit", "Tijd" ]))) else: return await ctx.send("Dit is geen geldige speeldag.")
async def matches(self, ctx, *args): args = list(args) # Default is current day if not args: args = [str(config.get("jpl_day"))] if all(letter.isdigit() for letter in args[0]): await ctx.send(getMatches(int(args[0]))) else: return await ctx.send("Dit is geen geldige speeldag.")
queue_lock = Lock() env_level = environ.get('dagr.queueman.logging.level', None) level_mapped = config.map_log_level( int(env_level)) if not env_level is None else None manager.set_mode('queueman') manager.init_logging(level_mapped) logger = logging.getLogger(__name__) regexes = { k: re.compile(v) for k, v in config.get('deviantart.regexes').items() } queue_slug = 'queue' cache = manager.get_cache() class waitingCount(): def __init__(self): self.__value = 0 def inc(self): self.__value += 1 def dec(self): self.__value -= 1
def parseArgs(day): semester = int(config.get("semester"))
async def les(self, ctx, *day): semester = int(config.get("semester")) year = int(config.get("year")) years_counter = int(config.get("years")) # Check if a schedule or a day was called if len(day) == 0: day = [] else: # Only either of them was passed if len(day) == 1: # Called a schedule if day[0].isdigit(): if 0 < int(day[0]) < years_counter + 1: year = int(day[0]) day = [] else: return await ctx.send("Dit is geen geldige jaargang.") # elif: calling a weekday is automatically handled below, # so checking is obsolete else: # Both were passed if day[0].isdigit(): if 0 < int(day[0]) < years_counter + 1: year = int(day[0]) day = [] else: return await ctx.send("Dit is geen geldige jaargang.") # Cut the schedule from the string day = day[1:] day = self.getWeekDay(None if len(day) == 0 else day)[1] dayDatetime = self.findDate(timeFormatters.weekdayToInt(day)) schedule = self.customizeSchedule(ctx, year, semester) # Create a date object to check the current week startDate = 1600041600 currentTime = dayDatetime.timestamp() week = clamp( timeFormatters.timeIn(currentTime - startDate, "weeks")[0], 1, 13) title, week = self.getTitle(day, dayDatetime, week) # Add all courses & their corresponding times + locations of today courses, extras, prev, online = self.getCourses(schedule, day, week) embed = discord.Embed(colour=discord.Colour.blue(), title=title) embed.set_author(name="Lessenrooster voor {}{} Bachelor".format( year, "ste" if year == 1 else "de")) if len(courses) == 0: embed.add_field(name="Geen Les", value="Geen Les", inline=False) else: courseString = self.createCourseString(courses) courseString += "\nGroep {} heeft vandaag online les.".format( 1 if week % 2 == 0 else 2) embed.description = courseString if prev: embed.add_field(name="Vakken uit vorige jaren", value=self.createCourseString(prev), inline=False) if extras: embed.add_field(name="Extra", value="\n".join( self.getExtras(extra) for extra in extras), inline=False) # Add online links if not commnet if online: embed.add_field(name="Online Links", value="\n".join( self.getLink(onlineClass) for onlineClass in online)) embed.set_footer( text="Semester {} | Lesweek {}".format(semester, round(week))) await ctx.send(embed=embed)