Example #1
0
	def handler( self, command_string ):
		msg = helpers.prependNick( command_string )
		msg += self.echo_message
		self.bot.privmsg( msg )
Example #2
0
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 )
Example #3
0
 def handler(self, command_string):
     msg = helpers.prependNick(command_string)
     msg += self.echo_message
     self.bot.privmsg(msg)
Example #4
0
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