Merge branch 'main' of https://github.com/hykilpikonna/GraphicsCardScripts
This commit is contained in:
+15
-4
@@ -1,5 +1,8 @@
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
import pygame
|
||||
import uvicorn
|
||||
from fastapi import FastAPI
|
||||
from pygame.mixer import Sound
|
||||
from telegram.ext import Updater, Dispatcher, CommandHandler
|
||||
@@ -17,6 +20,7 @@ sounds: list[Sound] = []
|
||||
async def alarm():
|
||||
s = Sound(AUDIO)
|
||||
s.play()
|
||||
sounds.append(s)
|
||||
return {'message': 'sound played'}
|
||||
|
||||
|
||||
@@ -25,15 +29,22 @@ async def stop():
|
||||
for s in sounds:
|
||||
s.stop()
|
||||
sounds.clear()
|
||||
return {'message': 'sound stopped'}
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
async def start_telegram():
|
||||
updater = Updater(token=TG_TOKEN)
|
||||
dispatcher: Dispatcher = updater.dispatcher
|
||||
bot = updater.bot
|
||||
|
||||
dispatcher.add_handler(CommandHandler('stop', stop))
|
||||
dispatcher.add_handler(CommandHandler('alarm', alarm))
|
||||
dispatcher.add_handler(CommandHandler('stop', lambda a, b: asyncio.run(stop())))
|
||||
dispatcher.add_handler(CommandHandler('alarm', lambda a, b: asyncio.run(alarm())))
|
||||
|
||||
print('Starting...')
|
||||
print('Starting Telegram...')
|
||||
updater.start_polling()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
pygame.mixer.init()
|
||||
asyncio.run(start_telegram())
|
||||
uvicorn.run(app, host="0.0.0.0", port=8000)
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user