Compare commits

...

51 Commits

Author SHA1 Message Date
tamservo
e5219bc433 Changed processing for race messages because of new format coming through. 2025-05-18 12:24:17 -04:00
tamservo
839ee6306c Added file locking to avoid db contention 2025-05-03 22:07:31 -04:00
tamservo
4b636eed7a Took user restrictions off starting race reporting. Tried to improve sql writes to fix db locking error. 2025-04-21 16:47:05 -04:00
tamservo
069d2ca7d0 Merge branch 'main' of https://git.sdf.org/tamservo/robottas
fix workflow testing branch issue.
2025-01-09 14:37:37 -05:00
tamservo
72f96a493b fixed silly comparison error. 2025-01-09 14:36:29 -05:00
Aaron Colon
e11b2396b6 Testing workflow. 2025-01-01 16:51:39 -05:00
Aaron Colon
0c7d721ddd testing workflow 2025-01-01 16:48:51 -05:00
tamservo
58fe1cdda6 Testing workflow 2025-01-01 16:44:12 -05:00
tamservo
9dd76e16b7 Update README.md 2025-01-01 16:43:36 -05:00
tamservo
a0be0c7607 Updated Readme.md. Testing new workflow. 2025-01-01 16:41:31 -05:00
tamservo
50a45e40d5 testing 2025-01-01 16:22:06 -05:00
tamservo
5b3ade2863 Update README.md 2025-01-01 16:20:27 -05:00
tamservo
93364b8580 fix check on half distance 2024-12-08 09:41:08 -05:00
tamservo
4d288e871c Changed permission filter for race commands because discord changed the name to remove the #<number> portion of the id name. 2024-12-01 17:12:07 -05:00
tamservo
c3716613fe Added missing required module to requirements.txt 2024-11-30 19:32:32 -05:00
tamservo
f853f6c220 Added set_total_laps for when they change the number in the laps in the race (i.e. false start procedure.) Also fixed check for race half distance. 2024-11-24 17:35:36 -05:00
tamservo@mx.sdf.org
fabecd836b Added encouragement, slight commands. 2024-09-27 16:22:31 -04:00
tamservo@mx.sdf.org
09bdd939f2 Added steer command. 2024-09-27 16:03:00 -04:00
tamservo@mx.sdf.org
c85d850218 Added new icons for Lawson, Antonelli, Bearman, and Colapinto. 2024-09-27 15:53:01 -04:00
tamservo@mx.sdf.org
083fd06395 Added beans emoji for Colapinto 2024-09-22 10:54:08 -04:00
tamservo@mx.sdf.org
2f9b0af5d8 moved \!in to \!inin 2024-08-13 13:32:33 -04:00
tamservo@mx.sdf.org
b5c4c988f0 added \!in 2024-08-13 13:28:46 -04:00
tamservo@mx.sdf.org
082c4c16b9 Updated rbhelp command 2024-05-19 15:26:23 -04:00
tamservo@mx.sdf.org
0e837958d9 Added help line for \!wall 2024-03-09 15:22:07 -05:00
tamservo
116d69ece9 added wall cmd. 2024-03-09 14:27:24 -05:00
tamservo
35f818d00d Logging messages from db. 2024-03-09 10:14:14 -05:00
tamservo
3f3b8c53b2 Setting up logging 2024-03-09 10:07:12 -05:00
tamservo
f197ae3ab5 Add icon for Bearman 2024-03-09 10:01:14 -05:00
tamservo
5b58bfbb84 Added binger. Fixed issue with delta string. 2024-03-07 21:00:01 -05:00
tamservo
b9f10ebb0e added variety of free squares 2024-02-17 10:25:31 -05:00
tamservo
cf2af10110 added bingo card commands 2024-02-17 08:41:15 -05:00
tamservo
745300c921 adding bingo module 2024-02-17 08:01:17 -05:00
tamservo
96e9b11bdf added iloveyoubot command 2024-01-08 10:22:31 -05:00
tamservo
c91c0e6e05 Fixes for time to next event / race. 2023-12-25 17:01:09 -05:00
tamservo
e960966a47 Merge branch 'main' of https://git.sdf.org/tamservo/robottas 2023-12-25 15:31:42 -05:00
tamservo
a4890aaccb commit 2023-12-25 15:31:38 -05:00
tamservo
e8fd9611d2 Add next_event and next_race 2023-12-25 15:28:15 -05:00
tamservo
51d5331d9d Fix send_image file handle issue. 2023-11-24 16:02:30 -05:00
tamservo
ddad2674d3 Fix variable name position 2023-11-24 15:53:56 -05:00
tamservo
986d76bd14 Merge remote-tracking branch 'origin/main' 2023-11-24 15:52:28 -05:00
tamservo
7234b0054d Formatting changes. 2023-11-24 15:41:42 -05:00
tamservo
0feeb6af30 Fix driverlist for unknown drivers 2023-11-24 04:57:56 -05:00
tamservo
756c38b0cb added penalty command 2023-10-21 14:23:02 -04:00
tamservo
ebfc44fa2d Fixed issue with calling some commands (removed pass_filter) 2023-10-07 09:21:02 -04:00
tamservo
5834927d3e Added forecast and undercut. 2023-08-27 17:25:15 -04:00
tamservo
b01511d052 Handle Lawson. Fix issue with start_collect when already collecting. 2023-08-26 05:47:10 -04:00
tamservo
4d602b7094 Removed print from RobottasSignalr.py 2023-07-30 21:19:34 -04:00
tamservo
dfd0f054a9 Fixed dict lookup issues. 2023-07-30 21:15:38 -04:00
tamservo
cfa71c5b23 Removed print statements, and changed flap order. 2023-07-30 21:00:07 -04:00
tamservo
c4955c4298 updated requirements.txt and bugfixes in robottas.py 2023-07-30 20:15:37 -04:00
tamservo
66eee52bb5 imported functionality from separte bot (Jenson Botton). 2023-07-30 19:47:08 -04:00
67 changed files with 1181 additions and 314 deletions

18
2024_schedule.csv Normal file
View 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
1 FORMULA 1 ARAMCO PRE-SEASON TESTING 2024 Practice 2024-02-21 12:00:00 Bahrain 0
2 FORMULA 1 ARAMCO PRE-SEASON TESTING 2024 Practice 2024-02-22 12:00:00 Bahrain 0
3 FORMULA 1 ARAMCO PRE-SEASON TESTING 2024 Practice 2024-02-23 12:00:00 Bahrain 0
4 FORMULA 1 GULF AIR BAHRAIN GRAND PRIX 2024 Practice 2024-02-29 11:30:00 Bahrain 1
5 FORMULA 1 GULF AIR BAHRAIN GRAND PRIX 2024 Practice 2024-02-29 15:00:00 Bahrain 1
6 FORMULA 1 GULF AIR BAHRAIN GRAND PRIX 2024 Practice 2024-03-01 11:30:00 Bahrain 1
7 FORMULA 1 GULF AIR BAHRAIN GRAND PRIX 2025 Qualifying 2024-03-01 15:00:00 Bahrain 1
8 FORMULA 1 GULF AIR BAHRAIN GRAND PRIX 2026 Race 2024-03-02 15:00:00 Bahrain 1
9 FORMULA 1 STC SAUDI ARABIAN GRAND PRIX 2024 Practice 2024-03-07 13:30:00 Saudi Arabia 2
10 FORMULA 1 STC SAUDI ARABIAN GRAND PRIX 2024 Practice 2024-03-07 17:00:00 Saudi Arabia 2
11 FORMULA 1 STC SAUDI ARABIAN GRAND PRIX 2024 Practice 2024-03-08 13:30:00 Saudi Arabia 2
12 FORMULA 1 STC SAUDI ARABIAN GRAND PRIX 2024 Qualifying 2024-03-08 17:00:00 Saudi Arabia 2
13 FORMULA 1 STC SAUDI ARABIAN GRAND PRIX 2024 Race 2024-03-09 17:00:00 Saudi Arabia 2
14 FORMULA 1 ROLEX AUSTRALIAN GRAND PRIX 2024 Practice 2024-03-22 01:30:00 Australia 3
15 FORMULA 1 ROLEX AUSTRALIAN GRAND PRIX 2024 Practice 2024-03-22 05:00:00 Australia 3
16 FORMULA 1 ROLEX AUSTRALIAN GRAND PRIX 2024 Practice 2024-03-23 01:30:00 Australia 3
17 FORMULA 1 ROLEX AUSTRALIAN GRAND PRIX 2024 Qualifying 2024-03-23 05:00:00 Australia 3
18 FORMULA 1 ROLEX AUSTRALIAN GRAND PRIX 2024 Race 2024-03-24 06:00:00 Australia 3

0
LICENSE Normal file → Executable file
View File

2
README.md Normal file → Executable file
View File

@@ -2,4 +2,4 @@
Discord bot for reporting F1 information.
Makes use of code from fastf1 python library (https://github.com/theOehrly/Fast-F1)
Makes use of code from fastf1 python library (https://github.com/theOehrly/Fast-F1)

31
RobottasSignalr.py Normal file → Executable file
View File

@@ -5,7 +5,10 @@ import logging
import requests
import time
import sqlite3
import sys
from contextlib import closing
from filelock import Timeout, FileLock
from fastf1.signalr_aio import Connection
import fastf1
@@ -84,6 +87,8 @@ class SignalRClient:
"SessionData", "LapCount"]
self.debug = debug
self.messages_db = 'messages.db'
self.messages_lock = FileLock('messages.lock')
self.filename = filename
self.filemode = filemode
self.timeout = timeout
@@ -91,9 +96,11 @@ class SignalRClient:
if not logger:
logging.basicConfig(
format="%(asctime)s - %(levelname)s: %(message)s"
format="%(asctime)s - %(levelname)s: %(message)s", \
stream=sys.stderr
)
self.logger = logging.getLogger('SignalR')
self.logger.warning("Created logger for SignalR")
else:
self.logger = logger
@@ -101,17 +108,15 @@ class SignalRClient:
self._t_last_message = None
def _to_file(self, msg):
"""
self._output_file.write(msg + '\n')
self._output_file.flush()
"""
print(msg)
con = sqlite3.connect('messages.db')
cur = con.cursor()
cur.execute("insert into messages (message) values(?)", (msg,))
con.commit()
cur.close()
con.close()
try:
with self.messages_lock:
with closing(sqlite3.connect(self.messages_db)) as con:
with closing(con.cursor()) as cur:
#self.logger.warning("about to log: " + msg)
cur.execute("insert into messages (message) values(?)", (msg,))
con.commit()
except:
print(f'Error writing message to db.')
async def _on_do_nothing(self, msg):
# just do nothing with the message; intended for debug mode where some
@@ -186,7 +191,7 @@ class SignalRClient:
f"[v{fastf1.__version__}]")
await asyncio.gather(asyncio.ensure_future(self._supervise()),
asyncio.ensure_future(self._run()))
self._output_file.close()
#self._output_file.close()
self.logger.warning("Exiting...")
def start(self):

BIN
alerts.db Normal file

Binary file not shown.

BIN
audio/bwoken.mp3 Normal file

Binary file not shown.

BIN
audio/no.mp3 Normal file

Binary file not shown.

BIN
bing/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

BIN
bing/10.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 KiB

BIN
bing/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 KiB

BIN
bing/3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 444 KiB

BIN
bing/4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

BIN
bing/5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 KiB

BIN
bing/6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 KiB

BIN
bing/7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB

BIN
bing/8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 KiB

BIN
bing/9.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 KiB

26
binger.py Executable file
View File

@@ -0,0 +1,26 @@
import glob
from random import randrange
import sqlite3
BING_IMGS_PATH = "bing/*"
DB = "bing.db"
def get_image_count():
# Choose a random image
bing_files = glob.glob(BING_IMGS_PATH)
image_idx = randrange(len(bing_files))
image = bing_files[image_idx]
# Get the latest count and increment
con = sqlite3.connect(DB)
cur = con.cursor()
cur.execute("UPDATE BING_COUNT SET COUNT = COUNT + 1")
con.commit()
result = cur.execute("SELECT COUNT FROM BING_COUNT")
count = result.fetchone()
count = count[0]
cur.close()
con.close()
return(image, count)

56
bingo.py Executable file
View File

@@ -0,0 +1,56 @@
import glob
from PIL import Image
from random import randrange
from uuid import uuid4
class Bingo:
"""Class which allows creation and cleanup of F1 bingo card images."""
def __init__(self):
self.LAYOUT_WIDTH = 88
self.X_OFFSET = 10
self.Y_OFFSET = 110
self.SQUARES_PATH = "bingo_images/squares/*.png"
self.FREE_SQUARES_PATH = "bingo_images/free_squares/*.png"
self.BLANK_CARD_PATH = "bingo_images/card_blank.png"
self.TEMP_FOLDER = "bingo_images/temp/"
def get_card(self):
square_files = glob.glob(self.SQUARES_PATH)
free_square_files = glob.glob(self.FREE_SQUARES_PATH)
used_files = set()
with Image.open(self.BLANK_CARD_PATH) as card_img:
card_img.load()
card_img = card_img.convert('RGBA')
# Fill the grid
for y in range(5):
for x in range(5):
square_file = ""
# If this is the center square, pick a random free square
if x == 2 and y == 2:
square_file = \
free_square_files[randrange(len(free_square_files))]
# otherwise, find a random file that hasn't been used yet
else:
rand_file_idx = randrange(len(square_files))
while rand_file_idx in used_files:
rand_file_idx = randrange(len(square_files))
square_file = square_files[rand_file_idx]
used_files.add(rand_file_idx)
with Image.open(square_file) as square:
position = (self.X_OFFSET + (x * self.LAYOUT_WIDTH),
self.Y_OFFSET + (y * self.LAYOUT_WIDTH))
card_img.paste(square, position, square)
# Write image to temp file
outfile = "".join((self.TEMP_FOLDER, str(uuid4()), ".png"))
print(f"{outfile=}")
card_img.save(outfile)
return outfile

BIN
bingo_images/card_blank.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

BIN
bingo_images/card_blank.xcf Normal file

Binary file not shown.

BIN
bingo_images/free_space.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

16
create_alerts_db.py Executable file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/python3
import sqlite3
if __name__ == '__main__':
con = sqlite3.connect('alerts.db')
cur = con.cursor()
cur.execute("""drop table alert_schedule""")
cur.execute("""drop table alert_channels""")
cur.execute("""create table alert_schedule( id integer primary key, type, day, hour, minute, last_sent );""")
cur.execute("""create table alert_channels( id integer primary key, type, channel_id);""")
con.commit()
cur.close()
con.close()

33
load_schedule.py Executable file
View 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()

BIN
races_backup.db Normal file

Binary file not shown.

View File

@@ -1,3 +1,6 @@
discord.py==2.2.3
beautifulsoup4==4.9.3
discord==2.2.3
fastf1==3.0.3
jdata==0.5.3
Requests==2.31.0
websockets==11.0.3

File diff suppressed because it is too large Load Diff

BIN
schedule.db Executable file

Binary file not shown.