java - Write message from IRC channel into a file with PircBotX -
hello pretty new java have fiddled bit.
this time trying make bot twitch channel can configure on own, making raffle , other independent stuff.
i using library connect twitch irc called pircbotx: https://code.google.com/p/pircbotx/ , have understanding on how answer listeneradapter so:
public class commands extends listeneradapter { public void onmessage(messageevent event) { if (event.getmessage().equals("!commands")) { event.respond("available user commands: !topic, !faq, !youtube, !twitter, !schedule, !time"); } } }
but in particular listener trying return message when person does:
!topic newtopic
in instance need "newtopic" string.
i don't know if there way save topic in twitch api write in own file.
i thinking might this:
newtext = event.getmessage.????? if (event.getmessage().equals("!topic " + newtext)) { if (event.getchannel().isop(event.getuser())) { try (bufferedwriter br = new bufferedwriter(new filewriter("topic.txt"))) { br.write(newtext); br.close(); event.getchannel().send().message("topic: " + newtext); } } else { event.respond("only mods can change topic"); } }
am doing wrong?
i have looked through api , don't understand how works. can help?
i might want answer own question people might similar dilemma.
this how declare string, easy:
string newtext = event.getmessage().substring(("!topic ").length());
i remember using substring() many times. little stupid mistake.
for more info on check here:
http://www.tutorialspoint.com/java/java_string_substring.htm
Comments
Post a Comment