def action( bot, line, socket ): if 'kick' in line.lower() and bot.nick in line: bot.privmsg( 'Ow' ) msg = chr( 1 ) + "ACTION kicks " + helpers.getnick( line ) + " back" + chr( 1 ) bot.privmsg( msg ) if 'hugs' in line.lower() and bot.nick in line: msg = chr( 1 ) + "ACTION hugs " + helpers.getnick( line ) + chr( 1 ) bot.privmsg( msg ) if 'kills' in line.lower() and bot.nick in line: msg = chr( 1 ) + "ACTION is a zombie." + chr( 1 ) bot.privmsg( msg ) msg = helpers.getnick( line ) + ': X|' bot.privmsg( msg ) if 'yawns' in line.lower(): msg = chr( 1 ) + "ACTION yawns" + chr( 1 ) bot.privmsg( msg )
def action(bot, line, socket): if 'kick' in line.lower() and bot.nick in line: bot.privmsg('Ow') msg = chr(1) + "ACTION kicks " + helpers.getnick(line) + " back" + chr( 1) bot.privmsg(msg) if 'hugs' in line.lower() and bot.nick in line: msg = chr(1) + "ACTION hugs " + helpers.getnick(line) + chr(1) bot.privmsg(msg) if 'kills' in line.lower() and bot.nick in line: msg = chr(1) + "ACTION is a zombie." + chr(1) bot.privmsg(msg) msg = helpers.getnick(line) + ': X|' bot.privmsg(msg) if 'yawns' in line.lower(): msg = chr(1) + "ACTION yawns" + chr(1) bot.privmsg(msg)
def command( bot, line, socket ): #This is run if the bot's command symbol, by default '!' is found command, commandstring = helpers.getCmdAndCmdString( line ) command = command.lower() if command == '': return if command in [ 'say', 'echo' ]: bot.privmsg( commandstring ) if command in [ 'topic' ]: msg = helpers.prependNick( commandstring ) bot.privmsg( msg + "Topic is: " + bot.channeltopic ) if command in [ 'yourcode' ]: msg = helpers.prependNick( commandstring ) msg += 'https://github.com/vinaysrao/ircbot.git' bot.privmsg( msg ) if command in [ 'god' ]: msg = helpers.prependNick( commandstring ) msg += 'http://www.youtube.com/watch?v=8nAos1M-_Ts' bot.privmsg( msg ) if command in [ 'addnick' ]: nick = helpers.getnick( line ) if commandstring == '' or len( commandstring.split() ) > 1: return if helpers.isAdmin( bot, nick ): if bot.addKnownNick( commandstring ): bot.privmsg( commandstring + ' added to known nicks' ) if command in [ 'kick' ]: msg = chr( 1 ) + "ACTION kicks " + commandstring + chr( 1 ) bot.privmsg( msg ) if command in [ 'lmgtfy' ]: if commandstring == '': return query = commandstring.split( ' ', 1 ) if helpers.isNewNick( query[ 0 ], bot.activeNickList ): msg = '' query = '+'.join( query ) else: msg = query[ 0 ] + ': ' query = '+'.join( query[ 1: ] ) query = '+'.join( query.split() ) url = 'http://www.lmgtfy.com/?q=' + query msg += url bot.privmsg( msg ) if command in [ 'define' ]: s = wordnet.synsets( commandstring ) try: msg = s[ 0 ].definition.capitalize() except: msg = 'Definition not found' if commandstring == 'god': msg = "\' \'" bot.privmsg( msg ) if command in [ 'quit' ]: if( helpers.isAdmin( bot, helpers.getnick( line ) ) ): bot.serializeNicks() __import__( 'sys' ).exit( 0 ) if command in [ 'restart' ]: if( helpers.isAdmin( bot, helpers.getnick( line ) ) ): bot.serializeNicks() __import__( 'sys' ).exit( 1 ) if command in [ 'list' ]: msg = helpers.prependNick( commandstring ) msg += ', '.join( helpers.commandList() ) bot.privmsg( msg ) if command in 'togglewelcome': if( helpers.isAdmin( bot, helpers.getnick( line ) ) ): bot.welcome_new = not bot.welcome_new msg = 'Bot\'s welcome mode: %s' % bot.welcome_new bot.privmsg( msg )
def privmsg( bot, line, socket ): if 'ping' in line.lower() and bot.nick in line: nick = helpers.getnick( line.split()[ 0 ] ) if nick: bot.privmsg( nick + ': Pong' )
def command(bot, line, socket): #This is run if the bot's command symbol, by default '!' is found command, commandstring = helpers.getCmdAndCmdString(line) command = command.lower() if command == '': return if command in ['say', 'echo']: bot.privmsg(commandstring) if command in ['topic']: msg = helpers.prependNick(commandstring) bot.privmsg(msg + "Topic is: " + bot.channeltopic) if command in ['yourcode']: msg = helpers.prependNick(commandstring) msg += 'https://github.com/vinaysrao/ircbot.git' bot.privmsg(msg) if command in ['god']: msg = helpers.prependNick(commandstring) msg += 'http://www.youtube.com/watch?v=8nAos1M-_Ts' bot.privmsg(msg) if command in ['addnick']: nick = helpers.getnick(line) if commandstring == '' or len(commandstring.split()) > 1: return if helpers.isAdmin(bot, nick): if bot.addKnownNick(commandstring): bot.privmsg(commandstring + ' added to known nicks') if command in ['kick']: msg = chr(1) + "ACTION kicks " + commandstring + chr(1) bot.privmsg(msg) if command in ['lmgtfy']: if commandstring == '': return query = commandstring.split(' ', 1) if helpers.isNewNick(query[0], bot.activeNickList): msg = '' query = '+'.join(query) else: msg = query[0] + ': ' query = '+'.join(query[1:]) query = '+'.join(query.split()) url = 'http://www.lmgtfy.com/?q=' + query msg += url bot.privmsg(msg) if command in ['google']: if commandstring == '': return query = commandstring.split(' ', 1) if helpers.isNewNick(query[0], bot.activeNickList): msg = '' query = '+'.join(query) else: msg = query[0] + ': ' query = '+'.join(query[1:]) query = '+'.join(query.split()) url = 'https://www.google.com/search?q=' + query msg += url bot.privmsg(msg) if command in ['define']: try: from nltk.corpus import wordnet except ImportError: bot.privmsg('NLTK Not found!') return s = wordnet.synsets(commandstring) try: msg = s[0].definition.capitalize() except: msg = 'Definition not found' if commandstring == 'god': msg = "\' \'" bot.privmsg(msg) if command in ['ud']: meaning = urbandict.define(commandstring) if meaning is not None: msg = meaning else: msg = "Definition not found" msg = ' '.join(msg.splitlines()) bot.privmsg(msg) if command in ['quit']: if (helpers.isAdmin(bot, helpers.getnick(line))): bot.serializeNicks() __import__('sys').exit(0) if command in ['restart']: if (helpers.isAdmin(bot, helpers.getnick(line))): bot.serializeNicks() __import__('sys').exit(1) if command in ['list']: msg = helpers.prependNick(commandstring) msg += ', '.join(helpers.commandList()) bot.privmsg(msg) if command in 'togglewelcome': if (helpers.isAdmin(bot, helpers.getnick(line))): bot.welcome_new = not bot.welcome_new msg = 'Bot\'s welcome mode: %s' % bot.welcome_new bot.privmsg(msg) if command in 'quiet': if (helpers.isAdmin(bot, helpers.getnick(line))): bot.quiet = not bot.quiet
def privmsg(bot, line, socket): if 'ping' in line.lower() and bot.nick in line: nick = helpers.getnick(line) if nick: bot.privmsg(nick + ': Pong')