def tg_water_meter(bot: telegram.Bot, update: telegram.Update): if update.message: message: telegram.Message = update.message else: message: telegram.Message = update.edited_message tg_group_id = message.chat_id # telegram group id forward_index = get_forward_index(tg_group_id=int(tg_group_id)) if message.forward_from_chat and message.forward_from_chat.type == 'channel': if update.message.forward_from_chat.id in global_vars.filter_list[ 'channels']: logger.debug('Message ignored: matched water meter channels') global_vars.drive_mode_on(forward_index, tg_user=message.from_user, tg_group_id=tg_group_id, tg_message_id=message.message_id) raise DispatcherHandlerStop() message_text = '' if message.caption: message_text = message.caption elif message.text: message_text = message.text if message.from_user.id in global_vars.filter_list['users']: logger.debug('Message ignored: matched filtered user') raise DispatcherHandlerStop() if not message_text: return for keyword in global_vars.filter_list['keywords']: if keyword in message_text: logger.debug('Message ignored: matched water meter keywords') update.message.reply_text( "Keyword detected, won't forward to QQ Group(keyword: " + keyword + ")") raise DispatcherHandlerStop()
def text_from_telegram(bot: telegram.Bot, update: telegram.Update): """ if update.message: message: telegram.Message = update.message edited = False else: message: telegram.Message = update.edited_message edited = True """ message: telegram.Message = update.effective_message edited = (bool(getattr(update, "edited_message", None)) or bool(getattr(update, "edited_channel_post", None))) tg_group_id = message.chat_id # telegram group id forward_index = get_forward_index(tg_group_id=tg_group_id) if forward_index == -1: return '' reply_entity = list() reply_entity.append({'type': 'text', 'data': {'text': message.text}}) qq_message_id = send_from_tg_to_qq(forward_index, message=reply_entity, tg_group_id=tg_group_id, tg_user=update.effective_user, tg_forward_from=message, tg_reply_to=message.reply_to_message, edited=edited) global_vars.mdb.append_message(qq_message_id, message.message_id, forward_index, 0)
def handle_group_decrease(context): qq_group_id = context.get('group_id') sub_type = context.get('sub_type') user_id = context.get('user_id') operator_id = context.get('operator_id') logger.debug(context) forward_index = get_forward_index(qq_group_id=qq_group_id) if forward_index == -1: return '' if sub_type == 'leave': if str(user_id) == str(QQ_BOT_ID): result = 'Your bot left the group.' else: qq_name = get_qq_name_encoded(user_id, forward_index) result = f'{qq_name} left the group.' elif sub_type == 'kick': qq_name = get_qq_name_encoded(user_id, forward_index) operator_name = get_qq_name_encoded(operator_id, forward_index) result = f'{qq_name} was kicked by {operator_name}.' else: operator_name = get_qq_name_encoded(operator_id, forward_index) result = f'Your bot was kicked by {operator_name}.' global_vars.tg_bot.sendMessage(chat_id=FORWARD_LIST[forward_index]['TG'], text=result, parse_mode='HTML') return ''
def handle_group_increase(context): qq_group_id = context.get('group_id') sub_type = context.get('sub_type') user_id = context.get('user_id') operator_id = context.get('operator_id') logger.debug(context) forward_index = get_forward_index(qq_group_id=qq_group_id) if forward_index == -1: return '' # reload namelist because there is a new member here global_vars.reload_qq_namelist(forward_index) qq_name = get_qq_name_encoded(user_id, forward_index) operator_name = get_qq_name_encoded(operator_id, forward_index) if sub_type == 'approve': result = f'{qq_name} approved by {operator_name} joined the group.' else: result = f'{qq_name} invited by {operator_name} joined the group.' global_vars.tg_bot.sendMessage(chat_id=FORWARD_LIST[forward_index]['TG'], text=result, parse_mode='HTML') return ''
def qq_drive_mode(context: dict): qq_group_id = context.get('group_id') qq_discuss_id = context.get('discuss_id') forward_index = get_forward_index(qq_group_id=qq_group_id, qq_discuss_id=qq_discuss_id) # prevent message leak if forward_index == -1: return '' if global_vars.DRIVE_MODE[forward_index]: # normal block return '' return {'pass': True}
def video_from_telegram(bot: telegram.Bot, update: telegram.Update): """ if update.message: message: telegram.Message = update.message edited = False else: message: telegram.Message = update.edited_message edited = True """ message: telegram.Message = update.effective_message edited = (bool(getattr(update, "edited_message", None)) or bool(getattr(update, "edited_channel_post", None))) tg_group_id = message.chat_id # telegram group id forward_index = get_forward_index(tg_group_id=tg_group_id) if edited: recall_message(forward_index, message) # don't forward this message if (message.caption and message.caption.startswith('//')) or ( message.reply_to_message and message.reply_to_message.caption and message.reply_to_message.caption.startswith('//')) or ( message.reply_to_message and message.reply_to_message.text and message.reply_to_message.text.startswith('//')): logger.debug('Message ignored: matched comment pattern') raise DispatcherHandlerStop() reply_entity = list() reply_entity.append({'type': 'text', 'data': {'text': '[ 视频 ]'}}) if message.caption: reply_entity.append({ 'type': 'text', 'data': { 'text': message.caption } }) qq_message_id = send_from_tg_to_qq(forward_index, message=reply_entity, tg_group_id=tg_group_id, tg_user=update.effective_user, tg_forward_from=message, tg_reply_to=message.reply_to_message, edited=edited) global_vars.mdb.append_message(qq_message_id, message.message_id, forward_index, 0)
def dice(tg_group_id: int, tg_user: telegram.User, tg_message_id: int, tg_reply_to: telegram.Message = None): forward_index = get_forward_index(tg_group_id=tg_group_id) if forward_index == -1: return reply_entity = list() reply_entity.append({'data': {'text': 'threw a dice'}, 'type': 'text'}) reply_entity.append({'data': {'type': '1'}, 'type': 'dice'}) send_from_tg_to_qq(forward_index, reply_entity, tg_group_id=tg_group_id, tg_user=tg_user)
def audio_from_telegram(bot: telegram.Bot, update: telegram.Update): message: telegram.Message = update.effective_message tg_group_id = message.chat_id # telegram group id forward_index = get_forward_index(tg_group_id=tg_group_id) reply_entity = list() reply_entity.append({'type': 'text', 'data': {'text': '[ 音频 ]'}}) qq_message_id = send_from_tg_to_qq(forward_index, message=reply_entity, tg_group_id=tg_group_id, tg_user=update.effective_user, tg_forward_from=message, tg_reply_to=message.reply_to_message) global_vars.mdb.append_message(qq_message_id, message.message_id, forward_index, 0)
def sticker_from_telegram(bot: telegram.Bot, update: telegram.Update): message: telegram.Message = update.effective_message tg_group_id = message.chat_id # telegram group id forward_index = get_forward_index(tg_group_id=tg_group_id) reply_entity = list() file_id = message.sticker.file_id if global_vars.JQ_MODE: tg_get_pic_url(file_id, 'png', False) reply_entity.append({ 'type': 'image', 'data': { 'file': file_id + '.png' } }) elif IMAGE_LINK_MODE[forward_index]: pic_url = tg_get_pic_url(file_id, 'png', True) reply_entity.append({ 'type': 'text', 'data': { 'text': '[ ' + message.sticker.emoji + ' sticker, 请点击查看' + pic_url + ' ]' } }) else: reply_entity.append({ 'type': 'text', 'data': { 'text': '[ ' + message.sticker.emoji + ' sticker ]' } }) qq_message_id = send_from_tg_to_qq(forward_index, message=reply_entity, tg_group_id=tg_group_id, tg_user=update.effective_user, tg_forward_from=message, tg_reply_to=message.reply_to_message) global_vars.mdb.append_message(qq_message_id, message.message_id, forward_index, 0)
def handle_group_upload(context): qq_group_id = context.get('group_id') user_id = context.get('user_id') file = context.get('file') logger.debug(context) forward_index = get_forward_index(qq_group_id=qq_group_id) if forward_index == -1: return '' qq_name = get_qq_name_encoded(user_id, forward_index) result = f'<b>{qq_name}</b> sent a 📎group file: {file["name"]}. Please view it on QQ.' global_vars.tg_bot.sendMessage(chat_id=FORWARD_LIST[forward_index]['TG'], text=result, parse_mode='HTML') return ''
def rps(tg_group_id: int, tg_user: telegram.User, tg_message_id: int, tg_reply_to: telegram.Message): forward_index = get_forward_index(tg_group_id=tg_group_id) if forward_index == -1: return reply_entity = list() reply_entity.append({ 'data': { 'text': 'played rock–paper–scissors' }, 'type': 'text' }) reply_entity.append({'data': {'type': '1'}, 'type': 'rps'}) send_from_tg_to_qq(forward_index, reply_entity, tg_group_id=tg_group_id, tg_user=tg_user)
def qq_command(context): if len(context['message']) > 1: # rich text can not be commands return {'pass': True} if context['message'][0][ 'type'] != 'text': # commands can only be pure text return {'pass': True} qq_group_id = context.get('group_id') qq_discuss_id = context.get('discuss_id') text = context['message'][0]['data']['text'] # get message text if not text.startswith('!!'): # no command indicator return {'pass': True} logger.debug('Command indicator met: ' + text) text = text[2:] for command in global_vars.command_list: # process all non-forward commands if command.qq_only and (text == command.command or text == command.short_command): logger.debug(f'Matched QQ only command: {command.command}') return command.handler(qq_group_id, qq_discuss_id, int(context['user_id'])) forward_index = get_forward_index(qq_group_id=qq_group_id, qq_discuss_id=qq_discuss_id) if forward_index == -1: logger.warning( 'Forward not found, please check your forward settings.') return '' for command in global_vars.command_list: # process all forward commands if not command.tg_only and not command.qq_only and ( text == command.command or text == command.short_command): logger.debug(f'Matched general command: {command.command}') return command.handler(forward_index, qq_group_id=qq_group_id, qq_discuss_id=qq_discuss_id, qq_user=int(context['user_id'])) return {'pass': True}
def tg_command(bot: telegram.Bot, update: telegram.Update): if update.edited_message: # handle edit message: telegram.Message = update.edited_message else: message: telegram.Message = update.message if not message.text.startswith('!!'): # no command indicator return tg_group_id = message.chat_id # telegram group id tg_reply_to = message.reply_to_message logger.debug('Command indicator met: ' + message.text) text = message.text[2:] for command in global_vars.command_list: # process all non-forward commands if command.tg_only and (text == command.command or text == command.short_command): logger.debug(f'Matched Telegram only command: {command.command}') command.handler(tg_group_id=tg_group_id, tg_user=message.from_user, tg_message_id=message.message_id, tg_reply_to=tg_reply_to) raise DispatcherHandlerStop() forward_index = get_forward_index(tg_group_id=tg_group_id) if forward_index == -1: logger.warning( 'Forward not found, please check your forward settings.') raise DispatcherHandlerStop() for command in global_vars.command_list: # process all forward commands if not command.tg_only and not command.qq_only and ( text == command.command or text == command.short_command): logger.debug(f'Matched general command: {command.command}') command.handler(forward_index, tg_user=message.from_user, tg_group_id=tg_group_id, tg_message_id=message.message_id, tg_reply_to=tg_reply_to) raise DispatcherHandlerStop()
def tg_drive_mode(bot: telegram.Bot, update: telegram.Update): """ if update.message: message: telegram.Message = update.message else: message: telegram.Message = update.edited_message """ message: telegram.Message = update.effective_message edited = (bool(getattr(update, "edited_message", None)) or bool(getattr(update, "edited_channel_post", None))) tg_group_id = message.chat_id # telegram group id forward_index = get_forward_index(tg_group_id=int(tg_group_id)) # prevent message leak if forward_index == -1: raise DispatcherHandlerStop() if global_vars.DRIVE_MODE[forward_index]: # normal block logger.debug('Telegram message ignored: drive mode is on') raise DispatcherHandlerStop()
def handle_forward(context): qq_group_id = context.get('group_id') qq_discuss_id = context.get('discuss_id') forward_index = get_forward_index(qq_group_id=qq_group_id, qq_discuss_id=qq_discuss_id) if forward_index == -1: return '' tg_message_id_list = send_from_qq_to_tg(forward_index, message=context['message'], qq_group_id=qq_group_id, qq_discuss_id=qq_discuss_id, qq_user=context['user_id']) # save message to database, using telegram message id as index for msg_id in tg_message_id_list: global_vars.mdb.append_message(context.get('message_id'), msg_id, forward_index, context.get('user_id')) return ''
def recall(tg_group_id: int, tg_user: telegram.User, tg_message_id: int, tg_reply_to: telegram.Message): forward_index = get_forward_index(tg_group_id=tg_group_id) if forward_index == -1: return result = recall_message(forward_index, tg_reply_to) if result == -1: text = 'Please refer to a message.' elif result == -2: text = 'Message not recallable.' elif result == -3: text = 'Recalling messages from other QQ users is not supported.', elif result == -4: text = 'Message sent more than two minutes ago. Recalling failed.' else: text = 'Message recalled.' global_vars.tg_bot.sendMessage(chat_id=tg_group_id, text=text, reply_to_message_id=tg_message_id)
def handle_group_admin(context): qq_group_id = context.get('group_id') sub_type = context.get('sub_type') user_id = context.get('user_id') logger.debug(context) forward_index = get_forward_index(qq_group_id=qq_group_id) if forward_index == -1: return '' qq_name = get_qq_name_encoded(user_id, forward_index) if sub_type == 'set': verb = 'promoted to admin.' else: verb = 'demoted to member.' result = f'{qq_name} was {verb}' global_vars.tg_bot.sendMessage(chat_id=FORWARD_LIST[forward_index]['TG'], text=result, parse_mode='HTML') return ''
def location_from_telegram(bot: telegram.Bot, update: telegram.Update): message: telegram.Message = update.effective_message tg_group_id = message.chat_id # telegram group id forward_index = get_forward_index(tg_group_id=tg_group_id) latitude = message.location.latitude longitude = message.location.longitude reply_entity = list() reply_entity.append({ 'type': 'text', 'data': { 'text': '分享了一个位置:' + get_location_from_baidu(latitude, longitude) } }) qq_message_id = send_from_tg_to_qq(forward_index, message=reply_entity, tg_group_id=tg_group_id, tg_user=update.effective_user, tg_forward_from=message, tg_reply_to=message.reply_to_message) global_vars.mdb.append_message(qq_message_id, message.message_id, forward_index, 0)
def tg_drive_mode(bot: telegram.Bot, update: telegram.Update): """ if update.message: message: telegram.Message = update.message else: message: telegram.Message = update.edited_message """ message: telegram.Message = update.effective_message edited = (bool(getattr(update, "edited_message", None)) or bool(getattr(update, "edited_channel_post", None))) tg_group_id = message.chat_id # telegram group id forward_index = get_forward_index(tg_group_id=int(tg_group_id)) if edited: recall_message(forward_index, message) # don't forward this message if (message.caption and message.caption.startswith('//') or message.text and message.text.startswith('//')) \ or (message.reply_to_message and message.reply_to_message.caption and message.reply_to_message.caption.startswith('//')) \ or (message.reply_to_message and message.reply_to_message.text and message.reply_to_message.text.startswith('//')): logger.debug('Message ignored: matched comment pattern') raise DispatcherHandlerStop() # prevent message leak if forward_index == -1: raise DispatcherHandlerStop() if global_vars.DRIVE_MODE[forward_index]: # normal block logger.debug('Telegram message ignored: drive mode is on') raise DispatcherHandlerStop()
def photo_from_telegram(bot: telegram.Bot, update: telegram.Update): """ handle photos sent from telegram :param bot: :param update: :return: """ message: telegram.Message = update.effective_message edited = (bool(getattr(update, "edited_message", None)) or bool(getattr(update, "edited_channel_post", None))) tg_group_id = message.chat_id # telegram group id forward_index = get_forward_index(tg_group_id=tg_group_id) reply_entity = list() photo = message.photo[-1] file_id = photo.file_id if global_vars.JQ_MODE: filename = tg_get_file(file_id) reply_entity.append({'type': 'image', 'data': {'file': filename}}) if message.caption: reply_entity.append({ 'type': 'text', 'data': { 'text': message.caption } }) elif IMAGE_LINK_MODE[forward_index]: filename = tg_get_file(file_id) pic_url = get_url(filename) if message.caption: reply_entity.append({ 'type': 'text', 'data': { 'text': '[ 图片, 请点击查看' + pic_url + ' ]' + message.caption } }) else: reply_entity.append({ 'type': 'text', 'data': { 'text': '[ 图片, 请点击查看' + pic_url + ' ]' } }) else: reply_entity.append({ 'type': 'text', 'data': { 'text': '[ 图片 ]' + message.caption } }) qq_message_id = send_from_tg_to_qq(forward_index, message=reply_entity, tg_group_id=tg_group_id, tg_user=update.effective_user, tg_forward_from=message, tg_reply_to=message.reply_to_message, edited=edited) global_vars.mdb.append_message(qq_message_id, message.message_id, forward_index, 0)
def document_from_telegram(bot: telegram.Bot, update: telegram.Update): """ if update.message: message: telegram.Message = update.message edited = False else: message: telegram.Message = update.edited_message edited = True """ message: telegram.Message = update.effective_message edited = (bool(getattr(update, "edited_message", None)) or bool(getattr(update, "edited_channel_post", None))) tg_group_id = message.chat_id # telegram group id forward_index = get_forward_index(tg_group_id=tg_group_id) if edited: recall_message(forward_index, message) # don't forward this message if (message.caption and message.caption.startswith('//')) or ( message.reply_to_message and message.reply_to_message.caption and message.reply_to_message.caption.startswith('//')) or ( message.reply_to_message and message.reply_to_message.text and message.reply_to_message.text.startswith('//')): logger.debug('Message ignored: matched comment pattern') raise DispatcherHandlerStop() reply_entity = list() if message.document.mime_type == 'video/mp4': file_id = message.document.file_id if global_vars.JQ_MODE: tg_get_pic_url(file_id, 'gif', False) if os.path.getsize(os.path.join(CQ_IMAGE_ROOT, file_id + '.gif')) > 5242880: reply_entity.append({ 'type': 'text', 'data': { 'text': '[ 视频:大小超过 5 MB ]' } }) else: reply_entity.append({ 'type': 'image', 'data': { 'file': file_id + '.gif' } }) if message.caption: reply_entity.append({ 'type': 'text', 'data': { 'text': message.caption } }) elif IMAGE_LINK_MODE[forward_index]: pic_url = tg_get_pic_url(file_id, 'gif', True) if message.caption: reply_entity.append({ 'type': 'text', 'data': { 'text': '[ 视频, 请点击查看' + pic_url + ' ]' + message.caption } }) else: reply_entity.append({ 'type': 'text', 'data': { 'text': '[ 视频, 请点击查看' + pic_url + ' ]' } }) else: reply_entity.append({'type': 'text', 'data': {'text': '[ 视频 ]'}}) elif message.document.mime_type == 'image/gif': file_id = message.document.file_id if global_vars.JQ_MODE: file = global_vars.tg_bot.getFile(file_id) file.download(custom_path=os.path.join(CQ_IMAGE_ROOT, file_id + '.gif')) reply_entity.append({ 'type': 'image', 'data': { 'file': file_id + '.gif' } }) if message.caption: reply_entity.append({ 'type': 'text', 'data': { 'text': message.caption } }) elif IMAGE_LINK_MODE[forward_index]: file = global_vars.tg_bot.getFile(file_id) file.download(custom_path=os.path.join(CQ_IMAGE_ROOT, file_id + '.gif')) pic_url = get_short_url(SERVER_PIC_URL + file_id + '.gif') if message.caption: reply_entity.append({ 'type': 'text', 'data': { 'text': '[ GIF, 请点击查看' + pic_url + ' ]' + message.caption } }) else: reply_entity.append({ 'type': 'text', 'data': { 'text': '[ GIF, 请点击查看' + pic_url + ' ]' } }) else: reply_entity.append({'type': 'text', 'data': {'text': '[ GIF ]'}}) else: reply_entity.append({'type': 'text', 'data': {'text': '[ 文件 ]'}}) qq_message_id = send_from_tg_to_qq(forward_index, message=reply_entity, tg_group_id=tg_group_id, tg_user=update.effective_user, tg_forward_from=message, tg_reply_to=message.reply_to_message, edited=edited) global_vars.mdb.append_message(qq_message_id, message.message_id, forward_index, 0)
def document_from_telegram(bot: telegram.Bot, update: telegram.Update): """ if update.message: message: telegram.Message = update.message edited = False else: message: telegram.Message = update.edited_message edited = True """ message: telegram.Message = update.effective_message edited = (bool(getattr(update, "edited_message", None)) or bool(getattr(update, "edited_channel_post", None))) tg_group_id = message.chat_id # telegram group id forward_index = get_forward_index(tg_group_id=tg_group_id) reply_entity = list() file_id = message.document.file_id if message.document.mime_type == 'video/mp4': file_id = message.document.file_id if global_vars.JQ_MODE: filename = tg_get_file(file_id, mp4=True) if os.path.getsize(os.path.join(CQ_IMAGE_ROOT, filename)) > 5242880: reply_entity.append({ 'type': 'text', 'data': { 'text': '[ 视频:大小超过 5 MB ]' } }) else: reply_entity.append({ 'type': 'image', 'data': { 'file': filename } }) if message.caption: reply_entity.append({ 'type': 'text', 'data': { 'text': message.caption } }) elif IMAGE_LINK_MODE[forward_index]: filename = tg_get_file(file_id, mp4=True) pic_url = get_url(filename) if message.caption: reply_entity.append({ 'type': 'text', 'data': { 'text': '[ 视频, 请点击查看' + pic_url + ' ]' + message.caption } }) else: reply_entity.append({ 'type': 'text', 'data': { 'text': '[ 视频, 请点击查看' + pic_url + ' ]' } }) else: reply_entity.append({'type': 'text', 'data': {'text': '[ 视频 ]'}}) elif message.document.mime_type == 'image/gif': if global_vars.JQ_MODE: filename = tg_get_file(file_id) reply_entity.append({'type': 'image', 'data': {'file': filename}}) if message.caption: reply_entity.append({ 'type': 'text', 'data': { 'text': message.caption } }) elif IMAGE_LINK_MODE[forward_index]: filename = tg_get_file(file_id) pic_url = get_url(filename) if message.caption: reply_entity.append({ 'type': 'text', 'data': { 'text': '[ GIF, 请点击查看' + pic_url + ' ]' + message.caption } }) else: reply_entity.append({ 'type': 'text', 'data': { 'text': '[ GIF, 请点击查看' + pic_url + ' ]' } }) else: reply_entity.append({'type': 'text', 'data': {'text': '[ GIF ]'}}) else: reply_entity.append({'type': 'text', 'data': {'text': '[ 文件 ]'}}) qq_message_id = send_from_tg_to_qq(forward_index, message=reply_entity, tg_group_id=tg_group_id, tg_user=update.effective_user, tg_forward_from=message, tg_reply_to=message.reply_to_message, edited=edited) global_vars.mdb.append_message(qq_message_id, message.message_id, forward_index, 0)
def photo_from_telegram(bot: telegram.Bot, update: telegram.Update): """ if update.message: message: telegram.Message = update.message edited = False else: message: telegram.Message = update.edited_message edited = True """ message: telegram.Message = update.effective_message edited = (bool(getattr(update, "edited_message", None)) or bool(getattr(update, "edited_channel_post", None))) tg_group_id = message.chat_id # telegram group id forward_index = get_forward_index(tg_group_id=tg_group_id) if edited: recall_message(forward_index, message) # don't forward this message if (message.caption and message.caption.startswith('//')) or ( message.reply_to_message and message.reply_to_message.caption and message.reply_to_message.caption.startswith('//')) or ( message.reply_to_message and message.reply_to_message.text and message.reply_to_message.text.startswith('//')): logger.debug('Message ignored: matched comment pattern') raise DispatcherHandlerStop() reply_entity = list() file_id = message.photo[-1].file_id if global_vars.JQ_MODE: tg_get_pic_url(file_id, 'jpg', False) reply_entity.append({ 'type': 'image', 'data': { 'file': file_id + '.jpg' } }) if message.caption: reply_entity.append({ 'type': 'text', 'data': { 'text': message.caption } }) elif IMAGE_LINK_MODE[forward_index]: pic_url = tg_get_pic_url(file_id, 'jpg', True) if message.caption: reply_entity.append({ 'type': 'text', 'data': { 'text': '[ 图片, 请点击查看' + pic_url + ' ]' + message.caption } }) else: reply_entity.append({ 'type': 'text', 'data': { 'text': '[ 图片, 请点击查看' + pic_url + ' ]' } }) else: reply_entity.append({ 'type': 'text', 'data': { 'text': '[ 图片 ]' + message.caption } }) qq_message_id = send_from_tg_to_qq(forward_index, message=reply_entity, tg_group_id=tg_group_id, tg_user=update.effective_user, tg_forward_from=message, tg_reply_to=message.reply_to_message, edited=edited) global_vars.mdb.append_message(qq_message_id, message.message_id, forward_index, 0)