Skip to content

Instantly share code, notes, and snippets.

@DV8FromTheWorld
Created June 9, 2014 01:10
Show Gist options
  • Save DV8FromTheWorld/4ba5e0264adb4c7248d6 to your computer and use it in GitHub Desktop.
Save DV8FromTheWorld/4ba5e0264adb4c7248d6 to your computer and use it in GitHub Desktop.
my $removeQuote = $dbh->prepare("DELETE FROM Quotes WHERE user = ? AND data = ?;");
case ".qlist" {
my $numArgs = @cmdargs;
if ($numArgs == 0) {
$irc->yield(notice => $nick, qq<Who would you like to see a list quotes of?>);
return;
}
if ($numArgs == 1) {
$getUserQuoteAll->execute(lc($cmdargs[0]));
my $result = $getUserQuoteAll->fetchall_arrayref({});
if (@$result == 0) {
$irc->yield(notice => $nick, 'No quotes found for ' . $cmdargs[0] . '.');
return;
}
foreach my $entry (@$result) {
$irc->yield(privmsg => $nick, '<' . $cmdargs[0] . '> ' . $entry->{data});
}
} else {
if ($isOp != 1) {
$irc->yield(notice => $nick, qq<Username should contain no spaces.>);
return;
}
elsif ($numArgs >= 3) {
if ($cmdargs[0] eq "remove") {
my $quote;
for (my $i = 2; $i <= $#cmdargs; $i++) {
$quote .= $cmdargs[$i] . " ";
}
chop($quote);
$removeQuote->execute($cmdargs[1], $quote);
$irc->yield(notice => $nick, qq<The Quote: $quote>);
$irc->yield(notice => $nick, qq<Removed $cmdargs[1]'s quote from Quote database.>);
}
else {
$irc->yield(notice => $nick, qq<.qlist Command not recognized. Proper arguments are: remove [key]>);
}
}
else {
$irc->yield(notice => $nick, qq<.qlist command not recognized. Too few arguments.>);
$irc->yield(notice => $nick, qq<Proper arguments are: remove [user] [quote]>);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment