import logging
from os import getenv
from telegram import Update
from telegram.ext import Application, CommandHandler, MessageHandler, filters
from dashgram import Dashgram
# Setup logging
logging.basicConfig(level=logging.INFO)
# Initialize SDK with environment variables
sdk = Dashgram(
project_id=getenv("PROJECT_ID"),
access_key=getenv("ACCESS_KEY")
)
async def start(update: Update, context):
await update.message.reply_text("Hello!")
async def echo(update: Update, context):
await update.message.reply_text(update.message.text)
def main():
application = Application.builder().token(getenv("BOT_TOKEN")).build()
# Add handlers
application.add_handler(CommandHandler("start", start))
application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, echo))
# Automatic tracking for all events
sdk.bind_telegram(application)
application.run_polling()
if __name__ == "__main__":
main()