def bot_run(): channel = get_channel() server = get_server() nickname = "test_bot" irc = IRC() irc.connect(server, channel, nickname) while True: text = filter_input(irc.get_text()) print text if check_msg(text, channel) and "test" in text.lower(): irc.send(channel, "Test successful!")
def main(channelName, serverName): channel = channelName if channelName.startswith('#') else '#' + channelName server = serverName nickname = "guru_bot" irc = IRC() irc.connect(server, channel, nickname) while 1: messageObj = irc.get_text() print(messageObj.all) if messageObj.type == MessageTypes.MESSAGE and messageObj.message.startswith( nickname): message = messageObj.message answer = AskGuru(message[message.find(nickname) + len(nickname):]) for line in answer.split('\n'): irc.send(channel, line)
def emoji_bot(): channel = get_channel() server = get_server() nickname = "emoji_bot" irc = IRC() irc.connect(server, channel, nickname) # Implicitly render Emojibot help on every successful connection attempt emoji_bot_help(irc, channel) # Infinite loop until disconnected while True: text = filter_input(irc.get_text()) print text # Retrieve Emojibot help whenever "emoji_bot --help" is called if check_msg(text, channel) and "emoji_bot --help" in text.lower(): emoji_bot_help(irc, channel) # -------------------- Various emojis implemented --------------------- if check_msg(text, channel) and "*smiles*" in text.lower(): irc.send( channel, emoji.emojize(':smiley:', use_aliases=True).encode("utf-8", "replace")) if check_msg(text, channel) and "*winks*" in text.lower(): irc.send( channel, emoji.emojize(':wink:', use_aliases=True).encode("utf-8", "replace")) if check_msg(text, channel) and "*laughs*" in text.lower(): irc.send( channel, emoji.emojize(':joy:', use_aliases=True).encode("utf-8", "replace")) if check_msg(text, channel) and "*fistbombs*" in text.lower(): irc.send( channel, emoji.emojize(':punch:', use_aliases=True).encode("utf-8", "replace")) if check_msg(text, channel) and "*heart*" in text.lower(): irc.send( channel, emoji.emojize(':hearts:', use_aliases=True).encode("utf-8", "replace")) if check_msg(text, channel) and "*smirks*" in text.lower(): irc.send( channel, emoji.emojize(':smirk:', use_aliases=True).encode("utf-8", "replace")) if check_msg(text, channel) and "*sleeps*" in text.lower(): irc.send( channel, emoji.emojize(':zzz:', use_aliases=True).encode("utf-8", "replace")) if check_msg(text, channel) and "*cool*" in text.lower(): irc.send( channel, emoji.emojize(':sunglasses:', use_aliases=True).encode("utf-8", "replace")) if check_msg(text, channel) and "*cries*" in text.lower(): irc.send( channel, emoji.emojize(':cry:', use_aliases=True).encode("utf-8", "replace")) if check_msg(text, channel) and "*tongue*" in text.lower(): irc.send( channel, emoji.emojize(':stuck_out_tongue:', use_aliases=True).encode("utf-8", "replace")) # Secret mic_drop emoji not included in the emoji_bot_help if check_msg(text, channel) and "*mic drop*" in text.lower(): irc.send( channel, emoji.emojize(':microphone:', use_aliases=True).encode("utf-8", "replace"))
def bot_run(): channel = get_channel() server = get_server() nickname = "THANOS" irc = IRC() irc.connect(server, channel, nickname) # Infinite loop until disconnected while True: text = filter_input(irc.get_text(), nums=True) print text if check_msg(text, channel) and "imperfectly balanced" in text.lower(): irc.send(channel, "Let's fix that shall we... *snap*") elif check_msg(text, channel) and "perfectly balanced" in text.lower(): irc.send(channel, "As all things should be") if check_msg(text, channel) and "imperfectly balanced"[::-1]\ in text.lower(): irc.send(channel, "Let's fix that shall we... *snap*") elif check_msg(text, channel) and "perfectly balanced"[::-1]\ in text.lower(): irc.send(channel, "As all things should be"[::-1]) if check_msg(text, channel) and "fun" in text.lower(): irc.send( channel, "Fun isn't something one considers when balancing the universe" ) if check_msg(text, channel) and "you should have gone for the head"\ in text.lower(): irc.send(channel, "*snap*")
def bot_run(): channel = get_channel() server = get_server() nickname = "spider_bot" irc = IRC() irc.connect(server, channel, nickname) # Infinite loop until disconnected while True: text = filter_input(irc.get_text()) print text if check_msg(text, channel) and "*snap*" in text.lower(): irc.send(channel, "Alexis...I don't feel so good...") irc.quit("disintegrated") if nickname == "spider_bot": nickname = "CAPTAIN_MARVEL" elif nickname == "CAPTAIN_MARVEL": nickname = "spider_bot" sleep(5) # Because quitting closes the connection with the server irc = IRC() irc.connect(server, channel, nickname) if check_msg(text, channel) and "goat" in text.lower(): with open("./static/battle_goat.txt", "r") as goat: lines = goat.readlines() for line in lines: irc.send(channel, line.strip("""\n""")) if check_msg(text, channel) and "pineapple" in text.lower(): with open("./static/pineapple.txt", "r") as pineapple: lines = pineapple.readlines() for line in lines: irc.send(channel, line.strip("""\n""")) if check_msg(text, channel)\ and ("tom brady" in text.lower() or "tb12" in text.lower() or "touchdown tommy" in text.lower()): irc.send(channel, "the GOAT") if check_msg(text, channel) and "spider_bot" in text.lower(): irc.send(channel, ":D") if check_msg(text, channel) and "the herd" in text.lower(): irc.send(channel, "ALL THE GOATS") if check_msg(text, channel) and "idea" in text.lower(): irc.send(channel, "it's gonna be YUUUGGEEE") if "QUIT" in text: irc.send(channel, "*mic drop*")
def send(self, msg, silent = False): """Sends a message to the IRC server.""" self.send_lock.acquire() IRC.send(self, msg, silent) self.send_lock.release()
#!/usr/bin/env python3 from irc import IRC import config import module import imp import sys import traceback sock = IRC() msg = sock.recv() while msg[1] != "376": msg = sock.recv() sock.send("MODE %s +B" % config.nick) sock.send("JOIN #cookiebot") sock.send("PRIVMSG #cookiebot :Hi!") mods = [] for m in config.modules: mod = imp.load_source(m + ".py", "modules/" + m + ".py") mods.append(mod.Module(sock)) del mod while True: msg = sock.recv() if msg[0] == "PING": sock.send("PONG %s" % msg[1]) for m in mods: m.ping() continue if ":darklink!" in msg[0]: try: if msg[3] == ":!quit" and msg[2] == "cookiebot": sock.send("QUIT") except:
from irc import IRC chatty = IRC("r4f1xd", "r4f1sBOTtom", "oauth:ckqni9uuiefzehgejl3lsy9nw79lnp") chatty.connect() chatty.send("AnotherTextmessage")
from irc import IRC import time irc = IRC('#EpiKnet') irc.connect('irc.epiknet.org','Philippe') #irc.epiknet.org time.sleep(5) irc.send('Salut MEC') time.sleep(2) while True: time.sleep(1) m = irc.recv() id = m.split('!')[0] id = id.lstrip(':') messages = m.split(' :') message = messages[-1] message = message.strip('\r\n') if m.find('PING') != -1: irc.ping() message = '' if len(message) != 0: if message.find('JOIN') != -1: print(id, 'a rejoint le channel') elif message == ' Je suis pas ton pote MEC' and id == 'Terrance': irc.send('Je suis pas ton mec MON GARS') time.sleep(1) #print(id, '>', message)