Update main.py
Browse files
main.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import logging
|
|
|
2 |
import shutil
|
3 |
import requests
|
4 |
import os
|
@@ -11,12 +12,13 @@ from pydub import AudioSegment
|
|
11 |
from telegram import Update
|
12 |
from telegram.ext import (ApplicationBuilder, CommandHandler, ContextTypes,
|
13 |
MessageHandler, filters)
|
|
|
14 |
a=[]
|
15 |
-
api_genai = os.
|
16 |
-
api_tele = os.
|
17 |
TELEGRAM_API_TOKEN = f"{api_tele}"
|
18 |
genai.configure(api_key=f'{api_genai}')
|
19 |
-
|
20 |
# logging.basicConfig(
|
21 |
# format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
22 |
# level=logging.INFO
|
@@ -87,7 +89,9 @@ async def echo(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
87 |
if text is not None and img is None:
|
88 |
model = genai.GenerativeModel('gemini-pro')
|
89 |
response = model.generate_content(text)
|
90 |
-
|
|
|
|
|
91 |
|
92 |
if __name__ == '__main__':
|
93 |
application = ApplicationBuilder().token(TELEGRAM_API_TOKEN).build()
|
|
|
1 |
import logging
|
2 |
+
import textwrap
|
3 |
import shutil
|
4 |
import requests
|
5 |
import os
|
|
|
12 |
from telegram import Update
|
13 |
from telegram.ext import (ApplicationBuilder, CommandHandler, ContextTypes,
|
14 |
MessageHandler, filters)
|
15 |
+
from keep_alive import keep_alive
|
16 |
a=[]
|
17 |
+
api_genai = os.getenv("gemini_api")
|
18 |
+
api_tele = os.getenv("tele_api")
|
19 |
TELEGRAM_API_TOKEN = f"{api_tele}"
|
20 |
genai.configure(api_key=f'{api_genai}')
|
21 |
+
keep_alive()
|
22 |
# logging.basicConfig(
|
23 |
# format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
24 |
# level=logging.INFO
|
|
|
89 |
if text is not None and img is None:
|
90 |
model = genai.GenerativeModel('gemini-pro')
|
91 |
response = model.generate_content(text)
|
92 |
+
r_text = response.text.replace('•', ' *')
|
93 |
+
r_warp=textwrap.indent(r_text, '> ', predicate=lambda _: True)
|
94 |
+
await context.bot.send_message(chat_id=update.effective_chat.id, text=r_warp, parse_mode="MARKDOWN")
|
95 |
|
96 |
if __name__ == '__main__':
|
97 |
application = ApplicationBuilder().token(TELEGRAM_API_TOKEN).build()
|