Browse Source

renaming triggers.py to command_handler.py

tags/v0.1
Ben Kurtovic 13 years ago
parent
commit
76c3d9dd3e
3 changed files with 8 additions and 8 deletions
  1. +0
    -0
      irc/command_handler.py
  2. +2
    -2
      irc/commands/help.py
  3. +6
    -6
      irc/frontend.py

irc/triggers.py → irc/command_handler.py View File


+ 2
- 2
irc/commands/help.py View File

@@ -4,7 +4,7 @@


from irc.base_command import BaseCommand from irc.base_command import BaseCommand
from irc.data import Data from irc.data import Data
from irc import triggers
from irc import command_handler


class Help(BaseCommand): class Help(BaseCommand):
def get_hook(self): def get_hook(self):
@@ -29,7 +29,7 @@ class Help(BaseCommand):


def do_command_help(self, data): def do_command_help(self, data):
command = data.args[0] command = data.args[0]
commands = triggers.get_commands()
commands = command_handler.get_commands()


dummy = Data() # dummy message to test which command classes pick up this command dummy = Data() # dummy message to test which command classes pick up this command
dummy.command = command dummy.command = command


+ 6
- 6
irc/frontend.py View File

@@ -6,7 +6,7 @@ import re
from config.irc_config import * from config.irc_config import *
from config.secure_config import * from config.secure_config import *


from irc import triggers
from irc import command_handler
from irc.connection import Connection from irc.connection import Connection
from irc.data import Data from irc.data import Data


@@ -19,7 +19,7 @@ def get_connection():
def startup(conn): def startup(conn):
global connection global connection
connection = conn connection = conn
triggers.init_commands(connection)
command_handler.init_commands(connection)
connection.connect() connection.connect()


def main(): def main():
@@ -43,7 +43,7 @@ def main():
data.nick, data.ident, data.host = re.findall(":(.*?)!(.*?)@(.*?)\Z", line[0])[0] data.nick, data.ident, data.host = re.findall(":(.*?)!(.*?)@(.*?)\Z", line[0])[0]
data.chan = line[2][1:] data.chan = line[2][1:]


triggers.check("join", data) # check if there's anything we can respond to, and if so, respond
command_handler.check("join", data) # check if there's anything we can respond to, and if so, respond


if line[1] == "PRIVMSG": if line[1] == "PRIVMSG":
data.nick, data.ident, data.host = re.findall(":(.*?)!(.*?)@(.*?)\Z", line[0])[0] data.nick, data.ident, data.host = re.findall(":(.*?)!(.*?)@(.*?)\Z", line[0])[0]
@@ -52,11 +52,11 @@ def main():


if data.chan == NICK: # this is a privmsg to us, so set 'chan' as the nick of the sender if data.chan == NICK: # this is a privmsg to us, so set 'chan' as the nick of the sender
data.chan = data.nick data.chan = data.nick
triggers.check("msg_private", data) # only respond if it's a private message
command_handler.check("msg_private", data) # only respond if it's a private message
else: else:
triggers.check("msg_public", data) # only respond if it's a public (channel) message
command_handler.check("msg_public", data) # only respond if it's a public (channel) message


triggers.check("msg", data) # check for general messages
command_handler.check("msg", data) # check for general messages


if data.msg.startswith("!restart"): # hardcode the !restart command (we can't restart from within an ordinary command) if data.msg.startswith("!restart"): # hardcode the !restart command (we can't restart from within an ordinary command)
if data.host in OWNERS: if data.host in OWNERS:


Loading…
Cancel
Save