Advertisement
peanutstick

Untitled

Apr 14th, 2021
735
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.33 KB | None | 0 0
  1. # Import some necessary libraries.
  2. import socket, ssl
  3.  
  4. # Some basic variables used to configure the bot
  5. server = "irc.evilcorp.ga" # Server
  6. port = 6697 # Port
  7. channel = "#lobby" # Channel
  8. botnick = "peanuttutu" # Your bots nick
  9.  
  10. def ping(): # This is our first function! It will respond to server Pings.
  11.   ircsock.send("PONG :pingis\n")
  12.  
  13. def sendmsg(chan , msg): # This is the send message function, it simply sends messages to the channel.
  14.   ircsock.send("PRIVMSG "+ chan +" :"+ msg +"\n")
  15.  
  16. def joinchan(chan): # This function is used to join channels.
  17.   ircsock.send("JOIN "+ chan +"\n")
  18.  
  19. def hello(): # This function responds to a user that inputs "Hello Mybot"
  20.   ircsock.send("PRIVMSG "+ channel +" :Hello!\n")
  21.  
  22. socketHandler = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  23. #ssl.create_default_context
  24. #ssl.create_default_context = ssl._create_unverified_context()
  25. #socketWraped = ssl.create_default_context().wrap_socket(socketHandler, server_hostname='irc.evilcorp.ga')
  26. ssl._create_default_https_context = ssl._create_unverified_context
  27. socketWraped = ssl.create_default_context().wrap_socket(socketHandler, server_hostname='irc.evilcorp.ga')
  28. #ssl.create_default_context = ssl._create_unverified_context()
  29. socketWraped.verify_mode = ssl.CERT_NONE
  30. socketWraped.check_hostname = False
  31.  
  32.  
  33. socketWraped.connect(('irc.evilcorp.ga', 6697))
  34.  
  35. #s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  36. #s.connect((server, port)) # Here we connect to the server using the port 6667
  37. ircsock = ssl.wrap_socket(socketWraped)
  38.  
  39.  
  40.  
  41.  
  42. ircsock.send("USER "+ botnick +" "+ botnick +" "+ botnick +" :This bot is a result of a tutoral covered on http://shellium.org/wiki.\n") # user authentication
  43. ircsock.send("NICK "+ botnick +"\n") # here we actually assign the nick to the bot
  44.  
  45. joinchan(channel) # Join the channel using the functions we previously defined
  46.  
  47. while 1: # Be careful with these! it might send you to an infinite loop
  48.   ircmsg = ircsock.recv(2048) # receive data from the server
  49.   ircmsg = ircmsg.strip('\n\r') # removing any unnecessary linebreaks.
  50.   print(ircmsg) # Here we print what's coming from the server
  51.  
  52.   if ircmsg.find(":Hello "+ botnick) != -1: # If we can find "Hello Mybot" it will call the function hello()
  53.     hello()
  54.  
  55.   if ircmsg.find("PING :") != -1: # if the server pings us then we've got to respond!
  56.     ping()
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement