daily pastebin goal
0%
SHARE
TWEET

Untitled

a guest Feb 4th, 2016 113 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # -*- coding: utf-8 -*-
  2.  
  3. """
  4. IRC #MZForum bot.
  5. BOT is designed to help users chat available its functionality.
  6. """
  7.  
  8. import yaml
  9. import socket
  10. import string
  11.  
  12.  
  13. class Malyna():
  14.  
  15.     def __init__(self):
  16.         self.irc_socket = socket.socket(socket.AF_INET,
  17.                                         socket.SOCK_STREAM)
  18.         config = yaml.load(open("config.yaml"))
  19.         server = config["server"]
  20.         port = config["port"]
  21.         channel = config["channel"]
  22.         nickname = config["nickname"]
  23.         prompt = config["prompt"]
  24.  
  25.         self.modt = False
  26.         self.irc_connect(server, port)
  27.         self.irc_login(nickname)
  28.         self.irc_join(channel)
  29.         self.test()
  30.  
  31.     def test(self):
  32.         read_buffer = ""
  33.         while True:  # While Connection is Active
  34.             read_buffer = read_buffer + self.ircSocket.recv(1024)
  35.             temp = string.split(read_buffer)
  36.             read_buffer = temp.pop()
  37.  
  38.     def send_data(self, command):
  39.         self.irc_socket.send(command + '\n')
  40.  
  41.     def irc_join(self, channel):
  42.         self.send_data("JOIN %s" % channel)
  43.  
  44.     def irc_login(self, nickname, username="username",
  45.                   password=None, realname="realname",
  46.                   hostname="hostname", servername="servername"):
  47.         self.send_data("USER %s %s %s %s" % (username,
  48.                                              hostname,
  49.                                              servername,
  50.                                              realname))
  51.         self.send_data("NICK " + nickname)
  52.  
  53.     def irc_connect(self, server, port):
  54.         self.irc_socket.connect((server, port))
  55.  
  56.  
  57. def main():
  58.     bot = Malyna()
  59.  
  60. if __name__ == "__main__":
  61.     main()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top