def main(): irc = IRC() irc.connect(config.HOST, config.PORT, config.CHANNEL, config.NICK) skyline = Skyline(config.BRIDGE_IP) skyline.start() stream_room = Group('Stream Room', lights=[ 'Roo side table', 'Lunar side table', 'Desk Portrait Left', 'Desk Portrait Right' ]) _thread.start_new_thread(irc.fill_user_list, ()) while True: response = irc.receive() # If Twitch pings the bot, respond. irc.respond_to_ping(response) username, message = irc.parse_message(response) # Custom commands insta_com = Command('insta', response='Follow r00 on Instagram at www.instagram.com/user_r00') twitter_com = Command('twitter', response='Follow r00 on Twitter at www.twitter.com/user_r00') ping_com = Command('ping', response='Pong') lights_com = Command('lights', response='Control r00\'s lighting with !lights and a color. For example, "!lights purple" will set the room lights to purple! For a full list of colors use !lightcolors.') # irc.process_command(response) if message.strip() == '!ping': irc.chat(ping_com.response) # Socials if message.strip() == "!insta": irc.chat(insta_com.response) elif message.strip() == '!twitter': irc.chat(twitter_com.response) # Shoutouts elif message.strip().split(' ')[0] == "!so": streamer_long = message.strip().split(' ')[1] streamer_short = streamer_long.replace('@', '') irc.chat(f'If you\'re looking for more interesting content, ' f'go check out {streamer_long} at ' f'https://twitch.tv/{streamer_short} ! Drop them a ' f'follow to be notified when they go live.') elif message.strip() == '!crash': # Get a light and collect its current colors for later. light = skyline.lights['Roo side table'] hue, sat, bri = light.hue, light.saturation, light.brightness # Create temporary light to hold current settings. temp_color = Color('temp', hue=hue, sat=sat, bri=bri) skyline.set_color(stream_room.lights, 'red') sleep(3) skyline.set_color(stream_room.lights, temp_color) # Skyline elif message.strip() == '!lights': irc.chat(lights_com.response) elif message.strip() == '!lightcolors': message = 'Lights can be set to ' counter = 0 for color in skyline.colors: if counter < len(skyline.colors.keys()) - 1: message = f'{message}{skyline.colors[color].name}, ' counter += 1 else: message = f'{message} or {skyline.colors[color].name}.' irc.chat(message) elif message.strip().split(' ')[0] == "!lights": color = message.strip().split(' ')[1] if color in skyline.colors: skyline.set_color(stream_room.lights, color) else: irc.chat('Honestly, I have no idea what you want.') elif message.strip() == '!rainbow': skyline.rainbow(stream_room.lights) sleep(1)
from pluginDriver import pluginDriver from irc import IRC from auth import auth bot = IRC("irc.freenode.net", 6697, "phukbot", "phukj00", "phuk3r", use_ssl=1) bot.raw("MODE phukbot +B") bot.join("#nopezor") driver = pluginDriver() driver.load_plugins("plugins", bot) authentication = auth(bot) authentication.auth_levels['phukd'] = 10 while bot.connected == 1: buffer = bot.receive() if not buffer: continue for buf in buffer: if not buf: continue (tmp, auth_level) = authentication.check(bot, buf) if not tmp: continue try: ret = driver.run_command(tmp, auth_level, authentication, bot) if not ret: continue
def init(bot): bot.connect(config.hostname, config.port, config.nickname, config.username, config.realname, config.channel, use_ssl=config.ssl, use_proxy=config.proxy, proxy_host=config.proxy_host, proxy_port=config.proxy_port) driver = pluginDriver() driver.load_plugins() return driver bot = IRC() driver = init(bot) while bot.socks != []: for sock, buffer in bot.receive(): if not buffer: if not hasattr(sock, 'reconnect') or sock.reconnect: driver.unload_plugins() time.sleep(2) driver = init(bot) continue for buf in buffer: if not buf: continue (tmp, auth_level) = sock.check(buf) if not tmp: continue