Search code examples
pythonbotsminecraftirc

IRC Bot for Minecraft is not working well


Tried to make an IRC Bot for a Minecraft server called "ORE" (Open Redstone). Btw it is Python. But it doesn't output anything, just empty line.

Here is the code:

import sys
import socket
import string
import time
from time import gmtime, strftime, sleep
import math
import re
from string import ascii_letters
from sys import argv
def main():
    operators = ["FreeProGamer"]
    server = "irc.openredstone.org"
    channel = "#openredstone"
    botnick = "FPGBot"
    readbuffer = ""

    irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #defines the socket
    print ("connecting to: "+server)
    irc.connect((server, 6667)) #connects to the server
    irc.send("PASS password\r\n")
    irc.send("USER "+ botnick +" "+ botnick +" "+ botnick + " :FPGBot\n") #user authentication
    irc.send("NICK "+ botnick +"\n")                            #sets nick
    sleep(5)
    irc.send("JOIN " + channel + "\r\n")        #join the chan
    irc.send("PRIVMSG OREBuild :/msg Jan1902 Hello!\r\n");

So I hope you will find a way to fix it. Oh and how do I check if a player is typing for example ;help and stuff? I wanna make this bot a bit more than a passive one :P


Solution

  • The answer is: As I am new to Python, I forgot to add main() at the end of the code, which calls the function main.