1919from telegram .utils .helpers import DEFAULT_NONE
2020from telegram .bot import Bot
2121from telegram .ext import *
22+ from telegram .error import NetworkError
2223from dateutil .parser import parse
2324from datetime import datetime , timedelta
2425from threading import Timer
@@ -118,6 +119,14 @@ def __init__(
118119 self .__check__ = True
119120 self .reporter = bug_reporter if bug_reporter else None
120121
122+ def handle_edited_msg (u : Update , c :CallbackContext ):
123+ #TODO: Handle editing messages
124+ # Handle messages editing in /send_all could be usefull
125+ # labels: enhancement
126+ u .edited_message .reply_text (self .strings ['edited-message' ])
127+
128+ self .dispatcher .add_handler (MessageHandler (Filters .update .edited_message ,handle_edited_msg ))
129+
121130 @self .command
122131 def start (update : Update , _ : CallbackContext ):
123132 chat = update .effective_chat
@@ -266,8 +275,6 @@ def set_interval(u: Update, c: CallbackContext):
266275 self .interval = int (c .args [0 ])
267276 self .__set_data__ (
268277 'interval' , self .interval , self .data_db )
269- #TODO: exception on message editing
270- # labels: bug
271278 u .message .reply_text ('✅ Interval changed to' + str (self .interval ))
272279 return
273280 u .message .reply_markdown_v2 ('❌ Bad command, use `/set_interval {new interval in seconds}`' )
@@ -847,6 +854,9 @@ def error_handler(update: object, context: CallbackContext) -> None:
847854 logging .error (msg = "Exception while handling an update:" ,
848855 exc_info = context .error )
849856
857+ if type (context .error ) is type (NetworkError ):
858+ return
859+
850860 # traceback.format_exception returns the usual python message about an exception, but as a
851861 # list of strings rather than a single string, so we have to join them together.
852862 tb_list = traceback .format_exception (
@@ -856,7 +866,7 @@ def error_handler(update: object, context: CallbackContext) -> None:
856866 s = traceback .extract_tb (tb )
857867 f = s [- 1 ]
858868 lineno = f .lineno
859- filename = f .filename
869+ filename = os . path . basename ( f .filename )
860870 exception_type = type (context .error ).__name__
861871 if self .reporter :
862872 self .reporter .bug (f'L{ lineno } @{ filename } : { exception_type } ' ,tb_string , {'line' :lineno , 'file' :filename })
@@ -1138,7 +1148,7 @@ def index(self):
11381148 max-height: 30%;
11391149 margin: auto;
11401150 background-color: #f39c12;
1141- color: #641e16 ;
1151+ color: black ;
11421152 border-radius: 10px;
11431153 padding: 10px;
11441154 overflow-x: auto;
@@ -1163,7 +1173,7 @@ def index(self):
11631173 lineno = content ['custom-prop' ]['line' ]
11641174 filename = content ['custom-prop' ]['file' ]
11651175 if os .path .exists (filename ):
1166- link = f' <a href="https://github.com/bsimjoo/Telegram-RSS-Bot/blob/main/{ filename } #L{ lineno } ">🔸L{ lineno } @{ filename } </a></h3>'
1176+ link = f' <a href="https://github.com/bsimjoo/Telegram-RSS-Bot/blob/main/{ filename } #L{ lineno } ">🔸may be here: L{ lineno } @{ filename } </a></h3>'
11671177 res += f'<h3>•Tag: <kbd>"{ tag } "</kbd> Count: { content ["count" ]} { link } </h3>'
11681178 res += f'<pre>{ content ["message" ]} </pre>'
11691179
0 commit comments