Permalink
Browse files

Merge remote branch 'upstream/master'

Conflicts:
	hooks/msg/tinyurl
  • Loading branch information...
2 parents 9ce26c1 + b416bf7 commit df6d543b72e8285a143e9c02e7dbbc87ee85e717 @limed committed Feb 20, 2012
View
@@ -6,4 +6,4 @@
##HACKABOT_HELP##
echo "sendnext"
-bc 2>&1
+bc -l 2>&1
@@ -69,6 +69,12 @@
<weather location="02129"/>
</commands>
+ <!-- Options for hooks (ie tinyurl) -->
+ <hooks>
+ <!-- Option to skip generating tinyurls for URIs containing sensitive information by regex pattern below -->
+ <tinyurl ignore="acme.widgets" />
+ </hooks>
+
<!-- Options for external inputs (ie email) -->
<external>
<email-rt ticket="https://rt.example.com/Ticket/Display.html?id=" />
@@ -95,6 +95,12 @@ sub cmd {
}
my $conn = $self->{'conn'};
+
+ if (defined $ENV{'HB_NETWORK'}) {
+ print $conn "net " . $ENV{'HB_NETWORK'} . "\n";
+ my $net_ret = <$conn>;
+ }
+
print $conn "$send\n";
my $ret = <$conn>;
@@ -252,20 +258,34 @@ sub counter_list {
}
sub quote_get {
- my ($self, $type) = @_;
+ my $self = shift;
+ my $type = shift;
+ my $search = shift; # optional
my ($dbh, $sth);
$dbh = $self->dbi or die;
- $sth = $dbh->prepare("SELECT `id`, `text` FROM
- `$type` ORDER BY RAND()*`lastused` ASC LIMIT 1");
+ # do some input validation
+ if (defined($search)) {
+ if ($search !~ /^%|%$/) {
+ $search = '%' . $search . '%';
+ }
+ $search = $dbh->quote($search);
+ $search = qq| WHERE `text` LIKE $search |;
+ } else {
+ $search = "";
+ }
+
+ my $sql = qq{SELECT `id`, `text` FROM `$type` $search
+ ORDER BY RAND()*`lastused` ASC LIMIT 1};
+ $sth = $dbh->prepare($sql);
$sth->execute or die;
my @row = $sth->fetchrow_array;
my $value = $row[1];
my $id = $row[0];
# Not sure why I originally used this format instead of just using
- # seconds since epoch, but I'll stick with it for compaitbility's sake.
+ # seconds since epoch, but I'll stick with it for compatibility's sake.
my $time = localtime->strftime("%y%m%d%H%M");
$dbh->do("UPDATE `$type` SET lastused = ? WHERE id = ?",
@@ -46,6 +46,11 @@ def cmd(self, send):
if not self.conn:
self.connect()
+ network = os.environ.get("HB_NETWORK", None)
+ if network
+ self.conn.write("net %s\n" % network)
+ ret = self.conn.readline()
+
self.conn.write("%s\n" % send)
ret = self.conn.readline()
@@ -36,6 +36,9 @@ def _handle_event(self, conn, event):
for key, val in conf.items():
vars["HB_%s" % key.upper()] = str(val)
+ if conn.network.id:
+ vars['HB_NETWORK'] = conn.network.id
+
vars['HB_NICK'] = conn.nickname
vars['HB_XML'] = ElementTree.tostring(conn.manager.config)
text = ""

0 comments on commit df6d543

Please sign in to comment.