Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import kik_unofficial.datatypes.xmpp.chatting as chatting
- from kik_unofficial.client import KikClient
- from kik_unofficial.datatypes.xmpp.roster import FetchRosterResponse, PeersInfoResponse, GroupSearchResponse
- from kik_unofficial.datatypes.xmpp.xiphias import UsersResponse, UsersByAliasResponse
- from kik_unofficial.callbacks import KikClientCallback
- from kik_unofficial.datatypes.xmpp.errors import SignUpError, LoginError
- from kik_unofficial.datatypes.xmpp.roster import GroupSearchResponse
- from kik_unofficial.datatypes.xmpp.login import LoginResponse, ConnectionFailedResponse
- username = sys.argv[1] if len(sys.argv) > 1 else input("Username: ")
- password = sys.argv[2] if len(sys.argv) > 2 else input('Password: ')
- def main():
- GifBot()
- class GifBot(KikClientCallback):
- def __init__(self):
- self.client = KikClient(self, username, password)
- def on_authenticated(self):
- print("I'm authenticated! You can now use the bot")
- def on_login_ended(self, response: LoginResponse):
- print("I'm logging in...")
- def on_group_message_received(self, chat_message: chatting.IncomingGroupChatMessage):
- JID = chat_message.group_jid #This grabs the groups JID.
- mssg = chat_message.body.lower()
- if mssg == ".ping": #command to check if bot is online
- self.client.send_chat_message(JID, "pong.")
- elif mssg.startswith(".jif"):
- gif_query = mssg.replace(".jif ", "", 1)
- self.client.send_chat_message(JID, "Searching for a gif with the query \"" + str(gif_query) + "\"...")
- try:
- self.client.send_gif_image(JID, gif_query)
- except:
- self.client.send_chat_message(JID, "I couldn't find a gif for the query " + gif_query + "\"!" )
- \
- # Error handling
- def on_connection_failed(self, response: ConnectionFailedResponse):
- print("[-] Connection failed: " + response.message)
- def on_login_error(self, login_error: LoginError):
- if login_error.is_captcha():
- login_error.solve_captcha_wizard(self.client)
- if __name__ == '__main__':
- main()
- while True: pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement