mirror of
https://git.sdf.org/tamservo/robottas.git
synced 2025-11-19 04:23:39 -05:00
Compare commits
4 Commits
51d5331d9d
...
c91c0e6e05
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c91c0e6e05 | ||
|
|
e960966a47 | ||
|
|
a4890aaccb | ||
|
|
e8fd9611d2 |
18
2024_schedule.csv
Normal file
18
2024_schedule.csv
Normal file
@@ -0,0 +1,18 @@
|
||||
FORMULA 1 ARAMCO PRE-SEASON TESTING 2024,Practice,2024-02-21 12:00:00,Bahrain,0
|
||||
FORMULA 1 ARAMCO PRE-SEASON TESTING 2024,Practice,2024-02-22 12:00:00,Bahrain,0
|
||||
FORMULA 1 ARAMCO PRE-SEASON TESTING 2024,Practice,2024-02-23 12:00:00,Bahrain,0
|
||||
FORMULA 1 GULF AIR BAHRAIN GRAND PRIX 2024,Practice,2024-02-29 11:30:00,Bahrain,1
|
||||
FORMULA 1 GULF AIR BAHRAIN GRAND PRIX 2024,Practice,2024-02-29 15:00:00,Bahrain,1
|
||||
FORMULA 1 GULF AIR BAHRAIN GRAND PRIX 2024,Practice,2024-03-01 11:30:00,Bahrain,1
|
||||
FORMULA 1 GULF AIR BAHRAIN GRAND PRIX 2025,Qualifying,2024-03-01 15:00:00,Bahrain,1
|
||||
FORMULA 1 GULF AIR BAHRAIN GRAND PRIX 2026,Race,2024-03-02 15:00:00,Bahrain,1
|
||||
FORMULA 1 STC SAUDI ARABIAN GRAND PRIX 2024,Practice,2024-03-07 13:30:00,Saudi Arabia,2
|
||||
FORMULA 1 STC SAUDI ARABIAN GRAND PRIX 2024,Practice,2024-03-07 17:00:00,Saudi Arabia,2
|
||||
FORMULA 1 STC SAUDI ARABIAN GRAND PRIX 2024,Practice,2024-03-08 13:30:00,Saudi Arabia,2
|
||||
FORMULA 1 STC SAUDI ARABIAN GRAND PRIX 2024,Qualifying,2024-03-08 17:00:00,Saudi Arabia,2
|
||||
FORMULA 1 STC SAUDI ARABIAN GRAND PRIX 2024,Race,2024-03-09 17:00:00,Saudi Arabia,2
|
||||
FORMULA 1 ROLEX AUSTRALIAN GRAND PRIX 2024,Practice,2024-03-22 01:30:00,Australia,3
|
||||
FORMULA 1 ROLEX AUSTRALIAN GRAND PRIX 2024,Practice,2024-03-22 05:00:00,Australia,3
|
||||
FORMULA 1 ROLEX AUSTRALIAN GRAND PRIX 2024,Practice,2024-03-23 01:30:00,Australia,3
|
||||
FORMULA 1 ROLEX AUSTRALIAN GRAND PRIX 2024,Qualifying,2024-03-23 05:00:00,Australia,3
|
||||
FORMULA 1 ROLEX AUSTRALIAN GRAND PRIX 2024,Race,2024-03-24 06:00:00,Australia,3
|
||||
|
33
load_schedule.py
Executable file
33
load_schedule.py
Executable file
@@ -0,0 +1,33 @@
|
||||
import csv
|
||||
import datetime
|
||||
import sqlite3
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
con = sqlite3.connect('schedule.db')
|
||||
cur = con.cursor()
|
||||
cur.execute("""drop table schedule""")
|
||||
|
||||
# Create the table
|
||||
cur.execute("""create table schedule( id integer primary key, """ +
|
||||
"""title, session_type, date_start,""" +
|
||||
"""location, round );""")
|
||||
|
||||
con.commit()
|
||||
|
||||
# Open the csv file
|
||||
with open("2024_schedule.csv") as csvfile:
|
||||
schedule_reader = csv.reader(csvfile, )
|
||||
for row in schedule_reader:
|
||||
sql_line = "INSERT INTO schedule (title, session_type, " + \
|
||||
"date_start, location, round) VALUES(" + \
|
||||
f"?, ?, ?, ?, ?)"
|
||||
|
||||
cur.execute(sql_line,
|
||||
(row)
|
||||
)
|
||||
con.commit()
|
||||
|
||||
cur.close()
|
||||
con.close()
|
||||
74
robottas.py
74
robottas.py
@@ -2,6 +2,7 @@
|
||||
|
||||
import asyncio
|
||||
import collections.abc
|
||||
import datetime
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
@@ -377,6 +378,8 @@ class Robottas(commands.Bot):
|
||||
driver = '???'
|
||||
if driver_num in self.driver_dict.keys():
|
||||
driver = self.driver_dict[driver_num]
|
||||
else:
|
||||
driver = driver_num
|
||||
|
||||
#self.driver_list[int(position) - 1] = self.driver_dict[driver_num]
|
||||
self.driver_list[int(position) - 1] = driver
|
||||
@@ -527,6 +530,65 @@ class Robottas(commands.Bot):
|
||||
return 'Not Watched Yet'
|
||||
else:
|
||||
return 'Watched Already'
|
||||
|
||||
|
||||
async def report_next_event(self, ctx):
|
||||
try:
|
||||
|
||||
tz = datetime.timezone.utc
|
||||
con = sqlite3.connect('schedule.db')
|
||||
cur = con.cursor()
|
||||
now_str = datetime.datetime.now(tz=tz).isoformat(sep=' ')
|
||||
now_str = now_str.split(".")[0]
|
||||
|
||||
query = 'select * from schedule where date_start > ? ' + \
|
||||
'order by date_start asc limit 1'
|
||||
|
||||
cur.execute(query, (now_str,))
|
||||
rows = cur.fetchall()
|
||||
|
||||
for row in rows:
|
||||
|
||||
t1 = datetime.datetime.fromisoformat(now_str)
|
||||
t2 = datetime.datetime.fromisoformat(row[3])
|
||||
delta = t2 - t1
|
||||
|
||||
message = f"The next event is the {row[1]} which is {delta} from now."
|
||||
await ctx.send(message)
|
||||
|
||||
break # There should only be one row anyway
|
||||
|
||||
except:
|
||||
await ctx.send("Sorry, hit the wall trying to find the answer...")
|
||||
|
||||
|
||||
async def report_next_race(self, ctx):
|
||||
try:
|
||||
tz = datetime.timezone.utc
|
||||
con = sqlite3.connect('schedule.db')
|
||||
cur = con.cursor()
|
||||
now_str = datetime.datetime.now(tz=tz).isoformat(sep=' ')
|
||||
now_str = now_str.split(".")[0]
|
||||
|
||||
query = "SELECT * FROM schedule WHERE date_start > ? AND " + \
|
||||
"session_type = 'Race' ORDER BY date_start ASC LIMIT 1"
|
||||
|
||||
cur.execute(query, (now_str,))
|
||||
rows = cur.fetchall()
|
||||
|
||||
for row in rows:
|
||||
t1 = datetime.datetime.fromisoformat(now_str)
|
||||
t2 = datetime.datetime.fromisoformat(row[3])
|
||||
delta = t2 - t1
|
||||
|
||||
message = f"The next race is the {row[1]} which is {delta} from now."
|
||||
await ctx.send(message)
|
||||
|
||||
break
|
||||
|
||||
except:
|
||||
await ctx.send("Sorry, hit the wall tring to find the next race.")
|
||||
|
||||
|
||||
def __init__(self):
|
||||
# Set debug or not
|
||||
@@ -900,6 +962,18 @@ class Robottas(commands.Bot):
|
||||
async def undercut(ctx):
|
||||
await self.send_image(ctx, "images/undercut.png")
|
||||
|
||||
## Calendar Commands
|
||||
|
||||
# Give days, hours, minutes until the next event
|
||||
@self.command()
|
||||
async def next_event(ctx):
|
||||
await self.report_next_event(ctx)
|
||||
|
||||
# Give days, hours, minutes until the next race
|
||||
@self.command()
|
||||
async def next_race(ctx):
|
||||
await self.report_next_race(ctx)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
rb = Robottas()
|
||||
|
||||
Reference in New Issue
Block a user