tomer8007 / kik-bot-api-unofficial

Python API for writing unoffical Kik bots that act like humans
MIT License
127 stars 77 forks source link

Python, I do not... #98

Closed GoodOldPhoenix closed 5 years ago

GoodOldPhoenix commented 5 years ago

Hi,

Sorry to be a huge pain in the a**, this is more of a cry for help rather than an issue with the API.

Due to there not being a JS version of this, I have forced myself to learn Python to hard way, dive right in, stare at letters and hope to piece them together using other bits laden throughout the project.

Unfortunately for me, this hasn't happened and I am quite stuck with neither Google nor Stack Exchange being able to accurately help me.

Anywho, I am trying to create command system (I say Jump, he says How high) but this is getting me absolutely nowhere: def on_group_message_received(self, chat_message: IncomingGroupChatMessage): if chat_message.body == "Hello": print("Someone said hello!")

XenXenOfficial commented 5 years ago

I got pretty little information to go off of here, but do you have

import kik_unofficial.datatypes.xmpp.chatting as chatting

Imported?

GoodOldPhoenix commented 5 years ago

I dont, let me import it and Ill update here once done

GoodOldPhoenix commented 5 years ago

So, I made that change and it did work, I saw my print in the console, I looked through the examples and the only thing I could find re sending a message back was:

client.send_chat_message(chat_message, "Message Here")

But on trying to reuse this, I get:

Exception in callback KikClient._on_new_data_received(b'<message to...i/></message>') handle: <Handle KikClient._on_new_data_received(b'<message to...i/></message>')> Traceback (most recent call last): File "C:\ProgramData\Anaconda3\lib\asyncio\events.py", line 145, in _run self._callback(*self._args) File "C:\Users\sdev1\Desktop\Bot\kik-bot-api-unofficial\kik_unofficial\client.py", line 289, in _on_new_data_received self._handle_xmpp_message(xml_element) File "C:\Users\sdev1\Desktop\Bot\kik-bot-api-unofficial\kik_unofficial\client.py", line 333, in _handle_xmpp_message self._handle_xmlns(xmpp_message['xmlns'], xmpp_message) File "C:\Users\sdev1\Desktop\Bot\kik-bot-api-unofficial\kik_unofficial\client.py", line 356, in _handle_xmlns self.xml_namespace_handlers[xmlns].handle(message) File "C:\Users\sdev1\Desktop\Bot\kik-bot-api-unofficial\kik_unofficial\xmlns_handlers.py", line 74, in handle self.callback.on_chat_message_received(IncomingChatMessage(data)) File "bot.py", line 37, in on_chat_message_received client.send_chat_message(chat_message, "hi!") File "C:\Users\sdev1\Desktop\Bot\kik-bot-api-unofficial\kik_unofficial\client.py", line 156, in send_chat_message if self.is_group_jid(peer_jid): File "C:\Users\sdev1\Desktop\Bot\kik-bot-api-unofficial\kik_unofficial\client.py", line 403, in is_group_jid if '@talk.kik.com' in jid: TypeError: argument of type 'IncomingChatMessage' is not iterable

XenXenOfficial commented 5 years ago

Hey sorry, chilling in bed haha. So what you're doing is sending the entire chat message object as the argument for the program to use as a JID, what you need to do is change

Client.send_chat_message(chat_message, "Message here")

To

Client.send_chat_message(chat_message.from_jid, "Message here")
GoodOldPhoenix commented 5 years ago

Solved by using the method shown in the echo_bot.py example

GoodOldPhoenix commented 5 years ago

Sorry, I completely missed your comment, thanks for that too 👍