电报Python-自动化连接并发送消息
尝试探索电报python并创建一个可以发送数据的自动化,但是目前我试图在测试期间将服务器与Centos连接到电报,我在运行Python脚本时收到了错误,是否有人知道我需要什么检查还是修改我的脚本?
错误:
Request caused struct.error: required argument is not an integer: SendMessageRequest(peer=InputPeerUser(user_id='user_id', access_hash='user_hash'), message='Testing...', no_webpage=False, silent=None, background=None, clear_draft=False, reply_to_msg_id=None, random_id=57746331822001234, reply_markup=None, entities=[], schedule_date=None)
api_id = 'telegram app id'
api_hash = 'telegram hash'
token = 'telegram token'
message = "Testing..."
phone = '213phoneNumber'
client = TelegramClient('session', api_id, api_hash)
client.connect()
if not client.is_user_authorized():
client.send_code_request(phone)
client.sign_in(phone, input('Enter the code:'))
try:
receiver = InputPeerUser('user_id', 'user_hash')
client.send_message(receiver, message, parse_mode='html')
except Exception as e:
print(e);
client.disconnect()
trying to explore telegram python and create an automation that can send data, but for now I'am trying to connect my server with centOS to telegram during my testing I received an error when I run the python script, is there someone know what I need to check or modify to my script?
Error:
Request caused struct.error: required argument is not an integer: SendMessageRequest(peer=InputPeerUser(user_id='user_id', access_hash='user_hash'), message='Testing...', no_webpage=False, silent=None, background=None, clear_draft=False, reply_to_msg_id=None, random_id=57746331822001234, reply_markup=None, entities=[], schedule_date=None)
api_id = 'telegram app id'
api_hash = 'telegram hash'
token = 'telegram token'
message = "Testing..."
phone = '213phoneNumber'
client = TelegramClient('session', api_id, api_hash)
client.connect()
if not client.is_user_authorized():
client.send_code_request(phone)
client.sign_in(phone, input('Enter the code:'))
try:
receiver = InputPeerUser('user_id', 'user_hash')
client.send_message(receiver, message, parse_mode='html')
except Exception as e:
print(e);
client.disconnect()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论