[+] Send diff as image rather than text
This commit is contained in:
+2
-4
@@ -7,7 +7,7 @@ from telegram import Bot, Update
|
|||||||
from telegram.ext import Updater, CallbackContext, Job
|
from telegram.ext import Updater, CallbackContext, Job
|
||||||
|
|
||||||
from src.database import Database
|
from src.database import Database
|
||||||
from src.utils import toJson, create, dictToString
|
from src.utils import toJson, create, dictToString, render
|
||||||
|
|
||||||
helpMsg = """
|
helpMsg = """
|
||||||
Welcome! This bot monitors http changes!
|
Welcome! This bot monitors http changes!
|
||||||
@@ -57,8 +57,6 @@ def createTaskCallback(user: str, taskName: str, request):
|
|||||||
cache[user] = {}
|
cache[user] = {}
|
||||||
|
|
||||||
def task(context: CallbackContext):
|
def task(context: CallbackContext):
|
||||||
print('request sent!')
|
|
||||||
|
|
||||||
# Send request
|
# Send request
|
||||||
text = sendRequest(request)
|
text = sendRequest(request)
|
||||||
|
|
||||||
@@ -72,7 +70,7 @@ def createTaskCallback(user: str, taskName: str, request):
|
|||||||
diff = ''.join(diffRaw)
|
diff = ''.join(diffRaw)
|
||||||
cache[user][taskName] = text
|
cache[user][taskName] = text
|
||||||
if diff != '':
|
if diff != '':
|
||||||
context.bot.send_message(chat_id=user, text='*%s Changed!*\n\n```diff\n%s```' % (taskName, diff), parse_mode="markdown")
|
context.bot.send_photo(chat_id=int(user), photo=BytesIO(render(diff)), caption='*%s Changed!*' % taskName, parse_mode='markdown')
|
||||||
return task
|
return task
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user