Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ A Telegram bot for interacting with the [WEEE-Open/grillo](https://github.com/WE
git clone https://github.com/yourusername/grillo-bot.git
cd grillo-bot
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
source venv/bin/activate # On Windows: venv\Scripts\activate powershell: .\venv\Scripts\Activate.ps1
pip install -r requirements.txt
cp .env.example .env
# Edit .env with your tokens
Expand Down
15 changes: 15 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ async def help(update: Update, context: ContextTypes.DEFAULT_TYPE, pre: str = ""
"/status - Check current lab status\n"
"/clockin - Clock in to the lab\n"
"/clockout - Clock out from the lab\n"
"/ring - Ring the bell at a location\n"
)

async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
Expand Down Expand Up @@ -136,6 +137,19 @@ async def clockout(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
logger.error(f"Error clocking out: {e}")
await update.effective_message.reply_text(f"❌ Error clocking out: {str(e)}")

async def ring(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
"""Ring the bell at a location."""
# Precompute to use in exception handling too
location_id = " ".join(context.args) if context.args else "default"
grillo = get_user_client_by_telegram(update.effective_user.id)
success = grillo.ring_location(location_id)
if success[0]:
await update.effective_message.reply_text(f"🔔 Successfully rang the bell at location '{location_id}'.")
elif not success[0] and "error" in success[1]:
await update.effective_message.reply_text(f"❌ Error ringing the bell: {success[1]['error']}")
else:
await update.effective_message.reply_text(f"❌ Failed to ring the bell at location '{location_id}'.")

async def unknown_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
"""Handle unknown commands."""
await update.effective_message.reply_text(
Expand Down Expand Up @@ -168,6 +182,7 @@ def main() -> None:
status,
clockin,
clockout,
ring,
]
aliases = {
"info": help,
Expand Down
3 changes: 2 additions & 1 deletion grillo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ def ring_location(self, location_id: str = "default") -> bool:
Returns:
True if successful
"""
raise NotImplementedError("ring_location method not implemented yet.")
res = self._make_request("POST", f"/locations/{location_id}/ring")
return res.json().get("success", False), res.json()

# Audit (lab time tracking) endpoints
def get_audits(self, date_string: Optional[str] = None, user: Optional[str] = None) -> List[Dict[str, Any]]:
Expand Down