Example #1
0
                # Now check if a bot is expecting a message, and pass it along.
                for bot in g.bots:
                    if bot.channel != channel:
                        continue
                    name = 'process_'+msg.params[1].upper()
                    if name == 'process_COMMENT':
                        pass
                    elif hasattr(bot, name):
                        process = getattr(bot, name)
                        process(msg.params)
                    elif bot.expecting:
                        bot.expecting(msg.params)
 

if __name__ == '__main__':
    
    server = 'localhost'
    if len(sys.argv) > 1:
        server = sys.argv[1]

    irc = Client(server, 'aigamedev',  port=6667, local_hostname='localhost')
    OnlineRound.client = irc
    h = ResistanceCompetitionHandler()
    irc.add_handler(h)
    try:
        irc.start()
        irc.join()
    except KeyboardInterrupt:
        h.upcoming.put(([], None))

Example #2
0
                                bot._sabotage.set(False)

                # Now check if a bot is expecting a message, and pass it along.
                for bot in g.bots:
                    if bot.channel != channel:
                        continue
                    name = 'process_' + msg.params[1].upper()
                    if name == 'process_COMMENT':
                        pass
                    elif hasattr(bot, name):
                        process = getattr(bot, name)
                        process(msg.params)
                    elif bot.expecting:
                        bot.expecting(msg.params)


if __name__ == '__main__':

    server = 'localhost'
    if len(sys.argv) > 1:
        server = sys.argv[1]

    irc = Client(server, 'aigamedev', port=6667, local_hostname='localhost')
    h = ResistanceCompetitionHandler()
    irc.add_handler(h)
    try:
        irc.start()
        irc.join()
    except KeyboardInterrupt:
        h.upcoming.put(([], None))
Example #3
0
"""
In this example, we have a basic 'hello world' IRC bot.
Upon joining the server and a channel, it will annouce 'Hello world!'.
Thereafter it will watch for any messages containing its nick (case-insensitive)
and respond to the sender with a "Hello, {sender}!"

Press ^C (ie. send SIGINT) to exit.
"""

import logging
import sys

from geventirc import Client

logging.basicConfig(level=logging.DEBUG)

host, nick, channel = sys.argv[1:4]

client = Client(host, nick=nick)
channel = client.channel(channel)

channel.join()
channel.msg("Hello world!")

@client.handler(command='PRIVMSG', payload=lambda value: nick.lower() in value.lower())
def mentioned(client, msg):
	channel.msg("Hello, {}!".format(msg.sender))

client.start()
client.join()