Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored message data to be an array of space separated words
- Loading branch information
1 parent
6eec33e
commit 928db6b
Showing
7 changed files
with
27 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
def message(pryme, message, source, target): | ||
if pryme.nick in message: | ||
if 'insult' in message: | ||
pryme.send(target, "Trip on thy sword, " + source + " !") | ||
if pryme.nick in message.pop(0): | ||
if 'insult' in message.pop(0): | ||
pryme.send(target, "Trip on thy sword, " + message.pop(0) + " !") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,10 @@ | ||
import re | ||
|
||
def message(pryme, message, source, target): | ||
if pryme.nick in message: | ||
if "join" in message: | ||
channel = parseChannel(message) | ||
if pryme.nick in message.pop(0): | ||
action = message.pop(0) | ||
channel = message.pop(0) | ||
if "join" in action: | ||
pryme.debug("Joining channel: " + channel) | ||
pryme.server.join(channel) | ||
if "part" in message: | ||
channel = parseChannel(message) | ||
if not channel: | ||
channel = target | ||
pryme.debug("Leaving channel: " + channel) | ||
pryme.server.part(channel) | ||
|
||
|
||
def parseChannel(message): | ||
channel = 0 | ||
try: | ||
p = re.compile('[#&][^\x07\x2C\s]{0,200}') | ||
m = p.search(message) | ||
channel = m.group() | ||
finally: | ||
return channel | ||
pryme.server.part(channel) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,9 @@ | ||
import re | ||
|
||
|
||
def message(pryme, message, source, target): | ||
if pryme.nick in message: | ||
if "addmodule" in message: | ||
moduleName = getModuleName(message) | ||
if source not in pryme.adminNick: | ||
return | ||
if pryme.nick in message.pop(0): | ||
if "addmodule" in message.pop(0): | ||
moduleName = message.pop(0) | ||
print 'Importing ' + moduleName | ||
module = __import__(moduleName) | ||
pryme.modules.append(module) | ||
|
||
|
||
def getModuleName(message): | ||
try: | ||
p = re.compile(':([^ ]+)') | ||
m = p.search(message) | ||
module = m.group()[1:] | ||
except: | ||
module = 0 | ||
pass | ||
|
||
return module | ||
pryme.modules.append(module) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
def message(pryme, message, source, target): | ||
if pryme.nick in message: | ||
if "reload" in message: | ||
if source not in pryme.adminNick: | ||
return | ||
|
||
if pryme.nick in message.pop(0): | ||
if "reload" in message.pop(0): | ||
for module in pryme.modules: | ||
pryme.debug("Reloading '" + str(module) + "'") | ||
reload(module) | ||
pryme.send(target, 'Modules Reloaded') | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
def message(pryme, message, source, target): | ||
if pryme.nick in message: | ||
if "test" in message: | ||
originalMessage = message[:] | ||
if pryme.nick in message.pop(0): | ||
if "test" in message.pop(0): | ||
pryme.send( | ||
target, | ||
"Message :'" + message + | ||
"Message :'" + originalMessage + | ||
"' from '" + source + | ||
"' in channel '" + target + "'" | ||
) |