|
Downgrade > Forums > > Библиотека pycq работает с KICQ.
<< < Page 1 of 1 > >>
Moderation History | New Thread | Reply | Subscribe
|
BitByByte
Member since Feb 25, 2025
|
Недавно, я наконец-то смог починить библиотеку pycq (написанную в 2001 году для Python версии 2.4) для полноценной работы с KICQ. Исходный код загружен на GitHub: https://github.com/tankwars92/pykicq.
Для того, чтобы было понятно, почему это - важно, давайте разберём пример кода (простейший бот):
c=pycq()
c.connect()
while True:
p=c.main(10)
print p
if p and isinstance(p, list) and len(p) > 0 and isinstance(p[0], dict):
if 'uin' in p[0] and 'message_text' in p[0]:
p_uin = p[0]['uin']
p_message_text = p[0]['message_text']
if p_message_text == "!test":
c.send_message_server(p_uin, 'Hi. This is the pycqlibrary, corrected to work with the OSCAR "KICQ" server. Random number (1-100): ' + str(random.randint(1, 100)) + " :D. Send !logout message to logout gracefully. Russian message test: \xcf\xf0\xe8\xe2\xe5\xf2.")
elif p_message_text == "!logout":
c.send_message_server(p_uin, "Goodbye!")
c.logout()
break
То есть, это ничуть не хуже всяких библиотек для Telegram или Discord ботов. Обратите внимание! Всегда корректно завершайте сессию с работой учётной записи: используйте c.logout()! Иначе, есть шанс получить "ошибку резервной схемы".
|
Posted Mar 30, 2025, 09:00 AM |
Quote
|
|