Connect problem ;Attribution error "irc_server"


So, i cant seem to find the problem with my code, it terminates with an object attribution error as follows;

self.irc.connect((self.irc_server, self.irc_port))
AttributeError: ‘Bot’ object has no attribute ‘irc_server’

cant seem to find the error, help would be really appreciated.

import socket
oauth_token = “oauth:thisisnotmyrealouth”

class Bot:
def init_(self):
self.irc_server = “
self.irc_port = 6667
self.oauth_token = oauth_token
self.username = “slimkimun”
self.channels = [“slimkimun”]

def send_privmsg(self, channel, text):
    self.send_command(f"PRIVMSG #{channel} :{text}")

def send_command(self, command):
    if "PASS" not in command:
        print(f"< {command}")
    self.irc.send((command + "\r\n").encode())

def connect(self):
    self.irc = socket.socket()
    self.irc.connect((self.irc_server, self.irc_port))
    self.send_command(f"PASS {self.oauth_token}")
    self.send_command(f"NICK {self.username}")
    for channel in self.channels:
        self.send_command(f"JOIN #{channel}")
        self.send_privmsg(channel, "Hey there!")

def handle_message(self, reveive_msg):
    print(f"> {received_msg}")

def loop_for_messages(self):
    while True:
        received_msgs = self.irc.recv(2048).decode()
        for received_msg in received_msgs.split("\r\n"):

def main():
bot = Bot()

if name == “main”:

Found my error

the init had one underscore to little.

can be closed.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.