Advertisement
Hey_Arnold

Gif Sending

May 23rd, 2022 (edited)
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.21 KB | None | 0 0
  1. import sys
  2. import kik_unofficial.datatypes.xmpp.chatting as chatting
  3. from kik_unofficial.client import KikClient
  4. from kik_unofficial.datatypes.xmpp.roster import FetchRosterResponse, PeersInfoResponse, GroupSearchResponse
  5. from kik_unofficial.datatypes.xmpp.xiphias import UsersResponse, UsersByAliasResponse
  6. from kik_unofficial.callbacks import KikClientCallback
  7. from kik_unofficial.datatypes.xmpp.errors import SignUpError, LoginError
  8. from kik_unofficial.datatypes.xmpp.roster import GroupSearchResponse
  9. from kik_unofficial.datatypes.xmpp.login import LoginResponse, ConnectionFailedResponse
  10.  
  11. username = sys.argv[1] if len(sys.argv) > 1 else input("Username: ")
  12. password = sys.argv[2] if len(sys.argv) > 2 else input('Password: ')
  13.  
  14. def main():
  15.     GifBot()
  16.  
  17. class GifBot(KikClientCallback):
  18.     def __init__(self):
  19.         self.client = KikClient(self, username, password)
  20.  
  21.     def on_authenticated(self):
  22.         print("I'm authenticated! You can now use the bot")
  23.  
  24.     def on_login_ended(self, response: LoginResponse):
  25.         print("I'm logging in...")
  26.  
  27.     def on_group_message_received(self, chat_message: chatting.IncomingGroupChatMessage):
  28.       JID = chat_message.group_jid  #This grabs the groups JID.
  29.       mssg = chat_message.body.lower()
  30.       if mssg == ".ping": #command to check if bot is online
  31.           self.client.send_chat_message(JID, "pong.")
  32.       elif mssg.startswith(".jif"):
  33.           gif_query = mssg.replace(".jif ", "", 1)
  34.           self.client.send_chat_message(JID, "Searching for a gif with the query \"" + str(gif_query) + "\"...")
  35.           try:
  36.               self.client.send_gif_image(JID, gif_query)
  37.           except:
  38.               self.client.send_chat_message(JID, "I couldn't find a gif for the query " + gif_query + "\"!" )
  39.                
  40.     \
  41.                      
  42.  
  43.    
  44.  
  45.  
  46.     # Error handling
  47.  
  48.     def on_connection_failed(self, response: ConnectionFailedResponse):
  49.         print("[-] Connection failed: " + response.message)
  50.  
  51.     def on_login_error(self, login_error: LoginError):
  52.         if login_error.is_captcha():
  53.             login_error.solve_captcha_wizard(self.client)
  54.  
  55.  
  56.  
  57. if __name__ == '__main__':
  58.     main()
  59.    
  60.     while True: pass
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement