pytdbot / client Goto Github PK
View Code? Open in Web Editor NEWEasy-to-use asynchronous TDLib wrapper for Python.
License: MIT License
Easy-to-use asynchronous TDLib wrapper for Python.
License: MIT License
How i can upload video in pytdbot ?
{
"@type": "error",
"code": 400,
"message": "Target chat must be non-empty"
}
I'm using pytdbot with this config:
client = Client(
api_id=VALUES['API_ID'],
api_hash=VALUES['API_HASH'],
database_encryption_key="1234echobot$",
token=VALUES['BOT_TOKEN'], # Your bot token or phone number if you want to login as user
files_directory="BotDB", # Path where to store TDLib files
lib_path="/usr/local/lib/libtdjson.so.1.8.29", # Path to TDjson shared library
td_log=LogStreamFile("tdlib.log"), # Set TDLib log file path
td_verbosity=3, # TDLib verbosity level
)
@client.on_updateNewMessage()
async def print_message(c: Client, message: Update):
print(message)
client.run()
When I send a message in my bot (created by botfather), I get this log messages in tdlib.log file:
[ 3][t 4][1716030841.368099212][ConnectionCreator.cpp:1027][#1][!ConnectionCreator][&connections] [hash:0xe8d0ca4a] wakeup
[ 3][t 4][1716030841.368463993][ConnectionCreator.cpp:820][#1][!ConnectionCreator][&connections] In client_loop: [client:0xe8d0ca4a]
[ 3][t 4][1716030841.368767023][ConnectionCreator.cpp:711][#1][!ConnectionCreator][&connections] Create: [[2001:b28:f23d:f001::a]:80] to DcId{1}
[ 2][t 4][1716030841.369091272][ConnectionCreator.cpp:888][#1][!ConnectionCreator] [[2001:b28:f23d:f001::a]:80] to DcId{1}: [PosixError : Network is unreachable : 101 : Failed to connect to [[2001:b28:f23d:f001::a]:80]]
[ 3][t 4][1716030841.369387149][ConnectionCreator.cpp:996][#1][!ConnectionCreator][&connections] [client:0xe8d0ca4a] set timeout in 0.099997
[ 3][t 4][1716030841.469857215][ConnectionCreator.cpp:1027][#1][!ConnectionCreator][&connections] [hash:0xe8d0ca4a] wakeup
[ 3][t 4][1716030841.470253229][ConnectionCreator.cpp:820][#1][!ConnectionCreator][&connections] In client_loop: [client:0xe8d0ca4a]
[ 3][t 4][1716030841.470546007][ConnectionCreator.cpp:996][#1][!ConnectionCreator][&connections] [client:0xe8d0ca4a] set timeout in 15.891231
[ 3][t 0][1716030841.877526044][Client.cpp:293][&td_requests] End to wait for updates, returning object 0 (nil)
[ 3][t 0][1716030841.878475189][Client.cpp:280][&td_requests] Begin to wait for updates with timeout 1.000000
I think it's because of internet filtering in my country! So, is there any way to use socks5 in pytdbot?
when use parameter device_model in client
auto detect CPython3.x
client = Client(
api_id=6,
api_hash="eb06d4abfb49dc3eeb1aeb98ae0f581e",
database_encryption_key="1234echobot$",
files_directory="BotDB", # Path where to store TDLib files
device_model='PC x64',
lib_path="./libtdjson.so.1.8.21", # Path to TDjson shared library
td_verbosity=1, # TDLib verbosity level,
options={
"ignore_background_updates": True,
}
)
E:\pythonProject\tg-td\venv\Scripts\python.exe E:\pythonProject\tg-td\main.py
[INFO][p 432 MainThread][1679412951.684244][tdjson.py:39][init] Initializing TDjson client with library: C:\Windows\system32\tdjson.dll
[INFO][p 432 MainThread][1679412951.699214][tdjson.py:80][_build_client] Using TDLib 1.8.12 (70bee089d)
Traceback (most recent call last):
File "E:\pythonProject\tg-td\main.py", line 69, in
client.run()
File "E:\pythonProject\tg-td\venv\lib\site-packages\pytdbot\client.py", line 433, in run
self._register_signal_handlers()
File "E:\pythonProject\tg-td\venv\lib\site-packages\pytdbot\client.py", line 1106, in _register_signal_handlers
self.loop.add_signal_handler(sig, _handle_signal)
File "D:\software\Microsoft Visual Studio\Shared\Python39_64\lib\asyncio\events.py", line 539, in add_signal_handler
raise NotImplementedError
NotImplementedError
进程已结束,退出代码1
This is an echo robot example, the code is copied as it is, only the ID is changed
My technique is not good enough. If possible, please answer.
thanks
this is my code:
@app.on_updateNewMessage()
async def reply_message(c: Client, message: Update):
print(await message.reply_text('test', quote=True, parse_mode='html'))
get this error
{
"@type": "error",
"code": 400,
"message": "Failed to parse JSON object as TDLib request: Unknown class \"messageReplyToMessage\""
}
version 0.8.6
How i can download document in pytdbot ?
I can't send messageAlbum
There is code
@client.on_updateNewMessage()
async def start(c: Client, message: Update):
user_id = message['message']['sender_id']['user_id']
if await redis.exists(f'{str(user_id)}_data') == 0:
if message.text == '/start':
# await c.sendPhoto(chat_id=user_id, photo=InputFileId(file3))
await c.sendMessageAlbum(chat_id=user_id, message_thread_id=0,
input_message_contents=[InputFileRemote(file1), InputFileRemote(file2)])
Error:
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\json\encoder.py", line 180, in default
raise TypeError(f'Object of type {o.class.name} '
TypeError: Object of type InputFileRemote is not JSON serializable
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.