Added twitterNotification method.
This commit is contained in:
parent
8976686286
commit
43e31ddf63
1 changed files with 24 additions and 15 deletions
|
@ -818,21 +818,7 @@ public class Mobibot extends PircBot {
|
||||||
public final void joinChannel() {
|
public final void joinChannel() {
|
||||||
joinChannel(ircChannel);
|
joinChannel(ircChannel);
|
||||||
|
|
||||||
if (twitterModule.isEnabled() && Utils.isValidString(twitterHandle)) {
|
twitterNotification("has joined " + ircChannel);
|
||||||
new Thread(() -> {
|
|
||||||
try {
|
|
||||||
twitterModule.post(
|
|
||||||
twitterHandle,
|
|
||||||
getName() + ReleaseInfo.VERSION + " has joined " + ircChannel,
|
|
||||||
true);
|
|
||||||
} catch (ModuleException e) {
|
|
||||||
if (logger.isWarnEnabled()) {
|
|
||||||
logger.warn(
|
|
||||||
"Failed to notify " + twitterHandle + " of joining " + ircChannel + " on Twitter.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1273,6 +1259,7 @@ public class Mobibot extends PircBot {
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
} else if (Commands.DIE_CMD.equals(cmd) && isOp(sender)) {
|
} else if (Commands.DIE_CMD.equals(cmd) && isOp(sender)) {
|
||||||
send(ircChannel, sender + " has just signed my death sentence.");
|
send(ircChannel, sender + " has just signed my death sentence.");
|
||||||
|
twitterNotification("killed by " + sender + " on " + ircChannel);
|
||||||
saveEntries(true);
|
saveEntries(true);
|
||||||
sleep(3);
|
sleep(3);
|
||||||
quitServer("The Bot Is Out There!");
|
quitServer("The Bot Is Out There!");
|
||||||
|
@ -1593,6 +1580,28 @@ public class Mobibot extends PircBot {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a notification to the registered Twitter handle.
|
||||||
|
*
|
||||||
|
* @param msg The twitter message.
|
||||||
|
*/
|
||||||
|
final void twitterNotification(final String msg) {
|
||||||
|
if (twitterModule.isEnabled() && Utils.isValidString(twitterHandle)) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
twitterModule.post(
|
||||||
|
twitterHandle,
|
||||||
|
getName() + ' ' + ReleaseInfo.VERSION + " " + msg, true);
|
||||||
|
} catch (ModuleException e) {
|
||||||
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn(
|
||||||
|
"Failed to notify @" + twitterHandle + ": " + msg, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Responds with the users on a channel.
|
* Responds with the users on a channel.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue