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
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();
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.
I have to implement custom search in my application for android 2.3.I have some EditText in which user type one letter and then I send response to the server, retrieve all the results matches this one letter and then I need to display them in a list. When user types second button I also need to send new response and refresh data and so on.
The question how can I do this in Android 2.3? What should i use?
This seems to be too open ended with too many questions to give a really helpful answer.
What you use in your app will heavily depend on how the server's API is expecting you to communicate. I, for one, am all for hiding the specifics of what a server does from the application and put all the "smarts" behind the API. So a query like:
http:/blah.com/getresults?search=a
would result in whatever matches 'a'. If it is searching a MySql Db, processing a Google search, or accessing files on the system doesn't matter.
Your code needs to worry about the interface to the API to make queries and processing the results, whether they're free formatted text, JSON objects, or whatever.
Maybe rewording your question or provide information on what you know would help.
My problem is that Asterisk seems to be answering the phone just a bit too late after the "Hello?" for the AMD functionality to work right, i.e. the AMD comes in on the silence and the person has to say hello again for it to know there's a person there.
We've tested it using IAX via a softphone and see more or less the same delay upon answering so we're assuming it's the Asterisk configuration.
I have more or less a vanilla Asterisk install. We are initiating outbound calls via SIP through a local provider. I'm using the "Manager" portion of the Java Asterisk API to tell Asterisk to make the call and then the Java Agi API to deal with it.
The SIP portion of the config looks like this (sip.conf):
[my-sip-trunk]
disallow=all
allow=ulaw
allow=alaw
allow=gsm
host=<ip to our provider>
type=peer
canreinvite=no
nat=never
The data I send via the Manager to Asterisk looks something like this:
Channel: SIP/<phonenumberhere>#my-sip-trunk
Context: MyContext
Extension: 100
Priority: 1
Caller ID: <caller's caller ID>
In my extensions.conf I have the appropriate info and-- solely for the purpose of this demonstration-- only a couple of commands:
[MyContext]
exten => 100,1,Answer()
exten => 100,n,Background(beep)
What happens is I pick up the phone, have time to say, "Hello?" and have the beep occur shortly after I finish speaking. The beep tells me when the AMD would have started listning-- but since it's past when I started speaking it will only hear silence.
Does anyone have any ideas where/how I've misconfigured Asterisk to have this delay?
SIP call progress analysis is notoriously fickle (it basically doesn't work).
What I've had to do in the past is use a SIP proxy that analyzes the audio in-band, and then passes the result back to Asterisk.
Check out Sangoma Call Analyzer.
I want to write a program that will be able to call into my company's bi-weekly conference calls, and record the call, so it can then be made into a podcast.
I am thinking of using Gizmo's SIP interface (and the fact that it allows you to make toll-free calls for free), but I am having trouble finding any example code (preferably in Java) that will be able to make an audio call, and get hold of the audio stream.
I have seen plenty of SIP programming tutorials that deal with establishing a session, and then they seem to just do some hand waving, and say "here is where you can establish the audio connection" without actually doing it.
I am experienced in Java, so I would prefer to use it, but other language suggestions are welcome as well.
I have never written a VOIP application, so I'm not really sure where to start. Can anyone suggest a good library or other resource that would help me get started?
Thanks!
Look for a VOIP softphone writtin in Java, then modify it to save the final audio stream instead of sending it to be played.
Side note: In many states you would be violating the law unless you do one of several things, varying by state: Notify the participants they're being recorded, insert BEEPs every N seconds, both, etc. Probably you only have to comply with the laws of the state you're calling from. Even worse, you may need to allow the users to decline recording (requires you to be there before recording starts). If you control the conference server, you may be able to get it to play a canned announcement that the call is being recorded.
You could do this with Twilio with almost no programming whatsoever. It will cost you 3ยข per minute, so if your company's weekly call is 45 minutes long, you're looking at $1.35 per week, about as close to free as possible. Here are the steps:
Sign up for Twilio and make note of your Account ID and token
Create a publicly accessible file on your web server that does nothing but output the following XML (see the documentation for explanation of the record parameters):
<Response>
<Record timeout="30" finishOnKey="#" />
</ Response>
When it's time to start the recording, perform a POST to this URL (documented here) with your browser or set up an automated process or script to do it for you:
POST http://api.twilio.com/2008-08-01/Accounts/ACCOUNT SID HERE/Calls
HTTP/1.1
Called=CONFERENCE NUMBER HERE
&Url=WEB PAGE HERE
&Method=GET
&SendDigits=PIN CODE HERE
If you want to get really creative, you can actually write code to handle the result of the recording verb and email the link to the MP3 or WAV file that Twilio hosts for you. But, if this is a one off, you can skip it because you can access all your recordings in the control panel for your account anyway.
try peers with mediaDebug option true in peers.xml. This option records all outgoing and incoming media streams in a media/ folder with a date pattern for file name. Nevertheless this file will probably not be usable as is. It contains raw uncompressed lienar PCM samples. You can use Audacity, sox or ffmpeg to convert it to whatever you want.
https://voip.dev.java.net/
They have some sample code there.