示例#1
0
def parser(me, line):
    # Let's grab the right target from PRIVMSG or NOTICE
    try: 
	if "PRIVMSG" in line[1] or "NOTICE" in line[1]:
	    if "#" in line[2]: target = line[2]
	    else: target = me.getnick(line[0])
    except: target = ""

    # Basic command management :P 
    try: cmd = line[3]
    except: cmd = ""
    try: args = line[4:] # Just be aware that this is still a list!
    except: args = ""

    if cmd == "!new" and me.nick == base_nick:
	# Creating new clients is as simple as running the class again!
	tnum = random.randint(1, 999)
	irc("%s%d" % (base_nick, tnum), host, channels=chan, parser=parser, debug=True)
    if cmd == "!say" and me.nick == base_nick:
	me.msg(target, args) # msg and notice doesn't care if you pass a list or string to it
    if cmd == "!autoconnect":
	if args[0] == "on" and not me.reconnect:
	    me.msg(target, "Setting auto-connect to on")
	    me.reconnect = True
	if args[0] == "off" and me.reconnect:
	    me.msg(target, "Setting auto-connect to off")
	    me.reconnect = False
    if cmd == "!quit":
	me.quit()
示例#2
0
import irclib
import ConfigParser

config = ConfigParser.RawConfigParser()
config.read('bot.cfg')

irc_server = config.get('irc_server_settings','irc_server')
irc_port = config.get('irc_server_settings','irc_port')
bot_connect_password = config.get('bot_settings','bot_connect_password')
bot_nick = config.get('bot_settings','twitch_user')
bot_ident = config.get('bot_settings','twitch_user')
bot_real_name = config.get('bot_settings','twitch_user')
bot_owner = config.get('bot_settings','twitch_user')
bot_autojoin_channels = config.get('bot_settings','bot_autojoin_channels')

myirc = irclib.irc(irc_server,irc_port,bot_nick,bot_ident,bot_real_name,bot_autojoin_channels,bot_connect_password)
myirc.connect()

示例#3
0
文件: bot.py 项目: jgallen23/EZTVbot
import irclib
import re
import os
import csv

data_file = os.path.expanduser("~/.eztvbot")

irc = irclib.irc("irc.efnet.pl", "6667", "jga_tv", "jgaPyBot", "jga tvdwnl", "#eztv", debug = False)

def read_data():
    if os.path.exists(data_file):
        return [row for row in csv.reader(open(data_file, 'rb'))]
    else:
        return []

def write_data(data):
    writer = csv.writer(open(data_file, 'wb'), quoting=csv.QUOTE_NONE)
    writer.writerows(data)

def data_received(data):
    """
    :^EZBot^[email protected] PRIVMSG #EZTV :Out now: American Idol S09E01 HDTV XviD-2HD - http://www.bt-chat.com/download.php?id=69578
    :^EZBot^[email protected] PRIVMSG #EZTV :Out now: American Idol S08E03 HDTV XviD-2HD - http://re.zoink.it/4b566e97
    MATCH %s [('\x02American Idol S08E03 HDTV XviD-2HD\x02', 'http://re.zoink.it/4b566e97\x02\x02\x02\x02\r')]
    """
    #print data
    if data.startswith(":^EZBot^"):
        data = data.replace("\x02", "").replace("\r", "")
        print data
        matches = re.compile(":\^EZBot\^!.*?Out now: (.*?) - (.*?)$").findall(data)
        if len(matches) != 0:
示例#4
0
    try: 
	if "PRIVMSG" in line[1] or "NOTICE" in line[1]:
	    if "#" in line[2]: target = line[2]
	    else: target = me.getnick(line[0])
    except: target = ""

    # Basic command management :P 
    try: cmd = line[3]
    except: cmd = ""
    try: args = line[4:] # Just be aware that this is still a list!
    except: args = ""

    if cmd == "!new" and me.nick == base_nick:
	# Creating new clients is as simple as running the class again!
	tnum = random.randint(1, 999)
	irc("%s%d" % (base_nick, tnum), host, channels=chan, parser=parser, debug=True)
    if cmd == "!say" and me.nick == base_nick:
	me.msg(target, args) # msg and notice doesn't care if you pass a list or string to it
    if cmd == "!autoconnect":
	if args[0] == "on" and not me.reconnect:
	    me.msg(target, "Setting auto-connect to on")
	    me.reconnect = True
	if args[0] == "off" and me.reconnect:
	    me.msg(target, "Setting auto-connect to off")
	    me.reconnect = False
    if cmd == "!quit":
	me.quit()

# Initialize the script:
irc(base_nick, host, channels=chan, parser=parser, reconnect=True, debug=True)
示例#5
0
文件: bot.py 项目: ctmnz/pythonIRC
import irclib
import ConfigParser

config = ConfigParser.RawConfigParser()
config.read('bot.cfg')

irc_server = config.get('irc_server_settings','irc_server')
irc_port = config.get('irc_server_settings','irc_port')

bot_nick = config.get('bot_settings','bot_nick')
bot_ident = config.get('bot_settings','bot_ident')
bot_real_name = config.get('bot_settings','bot_real_name')
bot_owner = config.get('bot_settings','bot_owner')
bot_autojoin_channels = config.get('bot_settings','bot_autojoin_channels')

myirc = irclib.irc(irc_server,irc_port,bot_nick,bot_ident,bot_real_name,bot_autojoin_channels)
myirc.connect()