From a9f2e56f63693ca7cd940792e73dca1502ca1d8d Mon Sep 17 00:00:00 2001 From: Tenzing Kandang Date: Wed, 29 Apr 2026 22:50:05 +0200 Subject: [PATCH 1/3] Supprimer bot/database.py --- bot/database.py | 61 ------------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 bot/database.py diff --git a/bot/database.py b/bot/database.py deleted file mode 100644 index f31cad7..0000000 --- a/bot/database.py +++ /dev/null @@ -1,61 +0,0 @@ -import sqlite3 - -class UserLocation: - def __init__(self, db_name='users_location.db'): - self.db_name = db_name - self.create_table() - - def create_table(self): - conn = sqlite3.connect(self.db_name) - cursor = conn.cursor() - cursor.execute(''' - CREATE TABLE IF NOT EXISTS user_locations ( - username TEXT NOT NULL, - user_id INTEGER PRIMARY KEY, - location TEXT NOT NULL - ) - ''') - conn.commit() - conn.close() - - def set_user_location(self, username:str, user_id: int, location: str): - conn = sqlite3.connect(self.db_name) - cursor = conn.cursor() - cursor.execute(''' - INSERT INTO user_locations (username, user_id, location) VALUES (?, ?, ?) ON CONFLICT(user_id) DO UPDATE SET location=excluded.location''', (username, user_id, location)) - conn.commit() - conn.close() - - def get_user_location(self, user_id: int) -> str: - conn = sqlite3.connect(self.db_name) - cursor = conn.cursor() - cursor.execute('SELECT location FROM user_locations WHERE user_id = ?', (user_id,)) - row = cursor.fetchone() - conn.close() - return row[0] if row else None - -class TaskCompleted: - def __init__(self, db_name='tasks_completed.db'): - self.db_name = db_name - self.create_table() - - def create_table(self): - conn = sqlite3.connect(self.db_name) - cursor = conn.execute(''' - CREATE TABLE IF NOT EXISTS task_completed ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - user_id INTEGER NOT NULL, - username TEXT NOT NULL, - task TEXT NOT NULL, - time TEXT NOT NULL - )''') - conn.commit() - conn.close() - - def set_info(self, user_id:int, username: str, task: str, time: str): - conn = sqlite3.connect(self.db_name) - cursor = conn.cursor() - cursor.execute(''' - INSERT INTO task_completed (user_id, username, task, time) VALUES (?, ?, ?, ?)''', (user_id, username, task, time)) - conn.commit() - conn.close() \ No newline at end of file From 7abbf0961e1176692d9c9d682d2d90f49e26b2cc Mon Sep 17 00:00:00 2001 From: Tenzing Kandang Date: Wed, 29 Apr 2026 22:50:15 +0200 Subject: [PATCH 2/3] Supprimer bot/task.py --- bot/task.py | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 bot/task.py diff --git a/bot/task.py b/bot/task.py deleted file mode 100644 index 3a58d0f..0000000 --- a/bot/task.py +++ /dev/null @@ -1,39 +0,0 @@ -import asyncio, json, datetime, discord -from discord.ui import View, Select - -class TaskSelect(Select): - def __init__(self, options): - super().__init__(placeholder="Choose a task to complete...", - min_values=1, max_values=1, options=options) - - async def callback(self, interaction: discord.Interaction): - payload = json.loads(self.values[0]) - tasklist_id = payload["tasklist_id"] - task_id = payload["task_id"] - - await interaction.response.defer(thinking=True) - try: - service = build_tasks_service() - task = await asyncio.to_thread(lambda: - service.tasks().get(tasklist=tasklist_id, task=task_id).execute()) - if not task: - await interaction.followup.send("Task not found.", ephemeral=True) - return - - now = datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc).isoformat() - body = dict(task) - body["status"] = "completed" - body["completed"] = now - - updated = await asyncio.to_thread(lambda: service.tasks().update(tasklist=tasklist_id, task=task_id, body=body).execute()) - - if updated.get("status") == "completed": - await interaction.followup.send("Failed to mark completed.", ephemeral=True) - - except Exception as e: - await interaction.followup.send(f"Error: {e}", ephemeral=True) - -class TasksView(View): - def __init__(self, options, timeout=120): - super().__init__(timeout=timeout) - self.add_item(TaskSelect(options)) \ No newline at end of file From 620a6e3b89083d30538b500bc5220e89c715eb44 Mon Sep 17 00:00:00 2001 From: Tenzing Kandang Date: Wed, 29 Apr 2026 22:50:22 +0200 Subject: [PATCH 3/3] Supprimer bot/weather.py --- bot/weather.py | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 bot/weather.py diff --git a/bot/weather.py b/bot/weather.py deleted file mode 100644 index 1279752..0000000 --- a/bot/weather.py +++ /dev/null @@ -1,34 +0,0 @@ -import requests -import os -from geopy.geocoders import Nominatim -from dotenv import load_dotenv - -load_dotenv() -WEATHER_TOKEN = os.getenv("WEATHER_TOKEN") - -class OpenWeatherMapAPIClient: - def __init__(self, api_token, name): - self.base_url = "https://api.openweathermap.org" - self._api_token = WEATHER_TOKEN - self.name = name - - def get_geodata(self, location): - geolocator = Nominatim(user_agent=self.name) - geodata = geolocator.geocode(location, language="en-us").raw - - return geodata["lat"], geodata["lon"] - - def get_current_weather(self, location, units="metric"): - url = f"{self.base_url}/data/2.5/weather" - lat, lon = self.get_geodata(location) - params = { - "lat": lat, - "lon": lon, - "units": units, - "appid": self._api_token, - } - - response = requests.get(url, params=params) - data = response.json() - - return data \ No newline at end of file