コード例 #1
0
ファイル: utils.py プロジェクト: Yoo-4x/telegram_bot
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})
コード例 #2
0
ファイル: utils.py プロジェクト: Yoo-4x/telegram_bot
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
コード例 #3
0
ファイル: utils.py プロジェクト: Yoo-4x/telegram_bot
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
コード例 #4
0
ファイル: utils.py プロジェクト: Yoo-4x/telegram_bot
def getUserId(username):
    result = tg.call_method('searchPublicChat', params={'username': username}, block=True)
    return result.update['id']
コード例 #5
0
ファイル: utils.py プロジェクト: Yoo-4x/telegram_bot
def getUsername(chat_id):
    result = tg.call_method('getUser', params={'user_id': chat_id}, block=True)
    return result.update['username']
コード例 #6
0
ファイル: utils.py プロジェクト: Yoo-4x/telegram_bot
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)
コード例 #7
0
ファイル: utils.py プロジェクト: Yoo-4x/telegram_bot
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