Spaces:
Runtime error
Runtime error
import logging | |
import os | |
import sys | |
import threading | |
sys.path.insert(0, "src") | |
os.environ['TRANSFORMERS_CACHE'] = '/tmp' | |
from telegram.ext import ( | |
Application, | |
) | |
from api import BuddyPanda | |
from functools import partial | |
from typing import List | |
from telegram import Update | |
from termcolor import colored | |
SELECT_COMMAND, GET_TEXT = range(2) | |
# Enable logging | |
logging.basicConfig( | |
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO | |
) | |
logger = logging.getLogger(__name__) | |
class LoggingDisabled: | |
"""Context manager that turns off logging within context.""" | |
def __enter__(self): | |
logging.disable(logging.CRITICAL) | |
def __exit__(self, exit_type, exit_value, exit_traceback): | |
logging.disable(logging.NOTSET) | |
def main() -> None: | |
app = Application.builder().token( | |
'5998527257:AAFolKz-AIXDzaSj3UOmxaLZSyDVp_3LoYw',).build() | |
run_agent( | |
agent=BuddyPanda( | |
token="hello", | |
application=app | |
) | |
) | |
print(f"Starting Agent...") | |
def run_agent(agent: BuddyPanda, as_api: bool = False) -> None: | |
agent.handlers() | |
if __name__ == "__main__": | |
main() |