def setChatMemberStatus(chat_id, user_id, opt): if opt == 'admin': # 管理员 status = {'@type': 'chatMemberStatusAdministrator', 'can_change_info': True, 'can_delete_messages': True, 'can_invite_users': True, 'can_restrict_member': True, 'can_pin_messages': True} elif opt == 'ban': # 封禁 status = {'@type': 'chatMemberStatusBanned'} elif opt == 'kick': # 踢出群/解除封禁 opt = 'chatMemberStatusLeft' status = {'@type': 'chatMemberStatusLeft'} elif opt == 're': # 恢复普通身份 status = {'@type': 'chatMemberStatusMember'} elif opt == 'no': status = {'@type': 'chatMemberStatusRestricted', 'is_member': True, 'permissions':{'@type': 'chatPermissions'}} opt = 'chatMemberStatusRestricted' return tg.call_method('setChatMemberStatus', params={'chat_id': chat_id, 'user_id': user_id, 'status': status})
def getMessage(chat_id, message_id): result = tg.call_method('getMessage', params={'chat_id': chat_id, 'message_id': message_id}, block=True) return result.update
def forwardMessage(chatId, chatId_from, message_id, send_copy=False): result = tg.call_method('forwardMessages', params={'chat_id':chatId, 'from_chat_id':chatId_from, 'message_ids': [message_id], 'send_copy': send_copy}, block=True) return result.update
def getUserId(username): result = tg.call_method('searchPublicChat', params={'username': username}, block=True) return result.update['id']
def getUsername(chat_id): result = tg.call_method('getUser', params={'user_id': chat_id}, block=True) return result.update['username']
def fileDownload(remote_file_id, priority=2, synchronous=False): result = tg.call_method('getRemoteFile', params={'remote_file_id':remote_file_id}, block=True) tg.call_method('downloadFile', params={'file_id':result.update['id'], 'priority':priority, 'synchronous':synchronous}, block=True)
def MessageReaded(chat_id, message_id): r = tg.call_method('getChat', params={'chat_id': chat_id}, block=True) if r.update['last_read_outbox_message_id'] >= message_id: return True else: return False