A friend and I (well a friend w/ me looking over the code to find any logical inconsistencies) are trying to write an IRC bot in Java mostly from scratch (that is, not using egg drop or other popular starting points). It's rather easy to detect a successful server join (socket.isConnected()), but I'm trying to figure out a way to detect a successful channel join. Basically, instead of just assuming that the join was successful, I want to be able to read from the server if the nick is moderated or banned or something else which prevents channel joining. Thanks!
Basically I want to be able to print out "Channel __ joined" if successful or "Channel ___ join failed" if the join wasn't successful. Is there anyway to do this? Thanks!
Edit: Upon further research, I'm now interested in learning how to decipher server message codes, specifically the format in which they're sent back to the client. Thanks!
Try reading through the RFC, particularly the JOIN command and the numeric replies. The Messages section explains the basics of sending messages back and forth. You should probably try to understand a protocol before you try to implement it though ;)
Related
I've been searching in a couple of topics here about this matter but I can't seem to get it right for Java.
QUESTION:
How can I send a message from my bot without the enduser having to start any conversation or have any kind of interaction?
If you use C#, you Can use telegram.api and below code:
bot.sendMessage.send(bot.chat_id,"Your Message").ToString();
I'm truly not sure how to word this correctly, but I'll try my best.
I want to send n emails to n recipients via a camel route and have those n recipients send approvals to the sender, which is done by using the world 'approve' in the subject, at which point, I'd trigger a process.
The first half of this task is done, as sending emails is a relatively simple task in Camel. Receiving is as well. My problem lies in the fact that I'd like to wait on these n emails to be received before continuing.
I'm using this code to attempt to do the latter half.
from("imaps://imap.gmail.com?username=emailaddress#gmail.com&" +
"password=RAW(password)&searchTerm.subject=approve")
.aggregate(header("*"), new UseLatestAggregationStrategy())
.completionSize(2)
.process(myProcess);
I know this code won't do exactly what I'm asking for, but it's what I'm working with for now. I'm getting this error when I drop the .jar into ServiceMix
org.apache.camel.CamelExchangeException: Invalid correlation key. Exchange[MailMessage:
I've tried looking up the error, but I haven't gotten much that's helpful. It's fairly obvious it's from either the header or the aggregation strategy, but again, I have yet to find anything useful for my situation.
Is there a better way to do this? I feel like my problems are coming from not completely understanding the nuances of camel, so there may very well be an easier/better way to achieve this. If not, what am I missing?
I apologize if I've left anything useful out. Feel free to ask questions.
You can use a constant as the correlation key if you want any message to be grouped together, for example:
.aggregate(constant(true), new UseLatestAggregationStrategy())
I'm fiddling around with the Java Pircbot 1.5.0 library and have successfully connected to the twitch chat irc and can send and respond to messages such as !time returning the current time. My bot's twitch account is a moderator on my channel and can do everything you would normally expect that I have tested for (ops, bans etc...)
What I'm now trying to do is replace existing messages so that I can build a simple profanity filter/ banned words filter.
effectively turning this (banned word is frogs):
queekusme: I like frogs
into:
queekusme: I like *****
however I can't find anything that would allow me to replace the existing message so that the word is removed.
I know this is possible as bots i have used in the past have been able to do this it's just that I can't find out how to do it on this thing called google.
I found twitch has in built filters however I found what I was looking for, I need to send a timeout command, this then does the in chat
PRIVMSG #[channel] :.timeout [UserToTimeOut] [TimeToTimeOut]
for reference
If you're not interested in helping a beginner in email parsing, don't read further.
I have been programming for a while so I know the gist of things. But, I'm really interested in creating a dummy email address and then set up a parsing program inside of it (if thats even how you do it)
Scenario:
I have an email account which receives certain emails which need parsing. I want to be able to forward those emails to a "dummy" email address which is basically just a program which parses the email for sender, subject, and message. I would prefer to write a runnable jar program or something on windows but I'm willing to do web programming if need be. Android programming is also an option for me.
What would I do to get started? I'm not asking for anyone to write out everything, I just need a starting point for all of this.
Thanks!
What you describe can be solved like this:
1/ Create a catch-all address *#yourdomain.com which will receive all incoming e-mails except those who match an existing email address (e.g. contact#yourdomain.col)
2/ Pipe all incoming e-mails to a script with Procmail
:0
| `/home/foouser/scripts/footool/footool.sh`
3/ Let the script process the e-mail (read headers, save in db, ...)
Another, probably much more easy solution would be to use a web service like cloudmailin.com for this. If the structure of the e-mail is always the same, an email parsing solution like mailparser.io could help you as well.
We're developing special devices that uses XMPP to talk to each other. A new API i am developing now, should talk to these devices too. The problem i am facing - all these devices are building little groups - for each customer we have... so we will have a chat-room for each group of devices, or, for each of our customer with his bunch of devices ;)
But now.. the api should be able to talk to every device that is connected. I don't need a real broadcast-mechanism - in the end, i will send a message only to one specific device..
But i don't want to login to each chat-room either - running a product with over 40k customers and much more devices, will end in a funny api, that is opening over 40k chat-rooms at startup... even if don't tried this yet, i can't imagine that an app like this will run well... even though we can have millions of customers in a few years.. i don't like solutions that will grow linear with the amount of customers, if you know what i mean :/
Now, basically i'm thinking of a solution, where i just can use the basic XMPPConnection to do my stuff.
MyCustomMessage msg = new MyCustomMessage();
msg.setTo("*"); // don't know what to address, i want to send it to "all"
msg.setFrom("ThatAPI"); // just a string telling that is sent from my java api ;)
msg.setEvent(event); // stuff that is coming through the parameters of the method where this code is inside
msg.setCustomStanza(data); // same here
connection.sendPacket(msg); // my try to send it to all till now..
Somewhere in the Ignite Realtime Forums i have read of one guy who "solved" it, but everything he says is "it's working now, i push my message through the sendPacket of Connection"... ok nice, my attempt of this seems not to work :(
Any better ideas/real implementations how this will work fine?
Basically i start to think that XMPP will not be the best technology to achieve something like this at all - i wish i could have a real/basic socket-implementation where something like this would be piece of cake.. But i can't choose - the third-party-system has implemented XMPP already... not enough time to change all of this... Just if you're wondering why we try this on XMPP..
You seem to have some conflicting requirements in that you want to send to all devices now, but only 1 specific device later. Are both models required at the same time, or do you plan on switching? How either is done would be different solutions.
As for your current approach, I think pubsub would make more sense than your chatroom approach, as that is oriented to generic message passing to subscribers.
You could set up a pubsub node per customer to send messages to all
of their devices.
As for a broadcast to all, you can make all devices
subscribe to a single pubsub node.
Thus you control broadcast and group messages by sending to the appropriate pubsub node.
For sending to a specific device, that is just a sendPacket to the specific entity, nothing really special there.