Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bitbotctl raw command. See description. #254

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/core_modules/bitbotctl-raw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#--depends-on commands

from src import IRCLine, ModuleManager, utils

class Module(ModuleManager.BaseModule):
def _id_from_alias(self, alias):
return self.bot.database.servers.get_by_alias(alias)
def _server_from_alias(self, alias):
id, server = self._both_from_alias(alias)
return server
def _both_from_alias(self, alias):
id = self._id_from_alias(alias)
if id == None:
raise utils.EventError("Unknown server alias")
return id, self.bot.get_server_by_id(id)

@utils.hook("control.raw")
def rawctl(self, event):
rawargs = str(event["data"]).split(" ", 1)
server = self._server_from_alias(rawargs[0])
if IRCLine.is_human(rawargs[1]):
line = IRCLine.parse_human(rawargs[1])
else:
line = IRCLine.parse_line(rawargs[1])
line = server.send(line)

if not line == None:
return "Sent: " + line.parsed_line.format()
else:
return "Line was filtered"
Comment on lines +27 to +30
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better just to assure() the line so it bypasses filtering altogether?