Trying to auth IRC bot to irc.twitch.tv (C++) - c++

So I'm trying to make an IRC bot that can connect to the Twitch.tv IRC servers using C++. So far, I've managed to get this bot to connect to IRC servers that don't require any sort of password, but I'm getting tripped up at the part where I need the bot to provide a password. So what I've currently got is:
(Connecting to the server)
send(cSock, "USER custom 0 0 <bot_name>\r\n", strlen("USER custom 0 0 <bot_name>\r\n"), NULL);
send(cSock, "PASS <twitch_oauth_token>\r\n", strlen("PASS <twitch_oauth_token>\r\n"), NULL);
send(cSock, "NICK <bot_name>\r\n", strlen("NICK <name>\r\n"), NULL);
(Joining a channel)
send(cSock, "JOIN #<channel_name>\r\n", strlen("JOIN #<channel_name>\r\n"), NULL);
send(cSock, "PRIVMSG #<channel_name> :Message\r\n", strlen("PRIVMSG #<channel_name> :Message\r\n"), NULL);
The bot will say a message upon joining a channel. I've tested this bot without the line containing PASS to connect to irc.quakenet.org without needing to provide authentication information, but I want to be able to have the bot provide authentication information to irc.twitch.tv so that I can use it on a registered account there.
What am I doing wrong?
Update:
Never mind...I figured out what I did wrong. Apparently I had to send the PASS before I sent the USER or NICK. Everything seems to be working alright at this point.
Thanks for all your help anyway.

What are you doing wrong?
Presumably, the server is telling you. Did you look at the conversation it's having with your bot? I'm assuming no, since you didn't paste it here.
Get a log of the conversation. Either have the bot print it out, or use a network packet sniffer such as tcpdump or Wireshark.

You must send the oauth password before you send the user.
[edit] saw where you updated[/edit]

Related

Get User Input From Lambda in AWS Connect

I was wondering if anybody has ever experimented with this issue I'm having and could give me any input on the subject.
As it stands right now I'm trying to see if there is a way to grab a users input through the AWS Connect. I understand that there is already a "Get User Input" block in the GUI that is available for me to use, unfortunately it does not offer the fine grain control I am looking for with requests and responses from Lex.
Right now I am able to Post Content to Lex and get responses just fine, as well as output speech using Amazon Polly via my Lambda. This works great for things that do not require a user to have to give feedback for a question.
For example if a client asks
"What time is my appointment?"
and we give back
"Your appointment is for X at X time, would you like an email with
this confirmation?"
I want to be able to capture what the user says back within that same lambda.
So the interaction would go like so:
User asks a question.
Lambda POST's it to Lex and gets a response
Amazon Polly says the response - i.e: 'Would you like an email to confirm?'
Lambda then picks up if the user says yes or no - POST's info to Lex
Gets response and outputs voice through Polly.
If anybody has any information on this please let me know, thank you!
Why do you make so much complications to implement IVR system using Amazon Connect. I have done the complete IVR automated system to one of my biggest US banking client. Use the below procedure to achieve what you desire.
Build a complete interactive lex bot(So that you can avoid amazon poly & using lex post content api). It is advised to build each bot has only one intent in it.
In connect using "Get User Input" node map the lex bot which you have created earlier with the question to be asked "What time is my appointment?". Once this question has been played the complete control goes to lex and then you fulfilled your intent from lex side, you can come back to connect as like that.
Refer AWS contact center for the clear idea.

C++, Mongoose: How to make a POST request?

I'm working on a project that uses Mongoose, and I need to make a POST request to another server. I don't see an example of how to do this in their examples list, does anyone know how to do this?
EDIT to add more detail:
I'm working within a larger C++ app and need to create a simple server such that a user can query the app for information. Right now, I start the server like this:
Status sampleCmd::startServer()
{
Status stat = MS::kSuccess;
struct mg_server *server;
// Create and configure the server
server = mg_create_server(NULL, ev_handler);
mg_set_option(server, "listening_port", "8080");
stopServer = false;
printf("Starting on port %s\n", mg_get_option(server, "listening_port"));
while (!stopServer) //for (;;)
{
mg_poll_server(server, 1000);
}
// Cleanup, and free server instance
mg_destroy_server(&server);
return stat;
}
In my event handler, I parse the provided URI for a particular one and then run some commands with the application's API. I need to send these results back to a server for the user to see. It's this latter step that is unclear to me. It seems odd that a web server library wouldn't have some client functionality, don't servers need to talk to other servers?
Okay, it turns out I was thinking about this wrong. I needed to respond to the POST request I was getting. So using mg_printf_data(...) with the connection object worked for me.

Unable send a message with stompclient

Iam trying to send a message to activemq using pythons stompclient.
https://bitbucket.org/hozn/stompclient/wiki/User%20Documentation
If there is a better library for this Im open to suggestions.
If i change to ip or port it will fail to connect so im assuming that the connection is working. There are no errors when I run this code its just that I see no messages on the queue. I think the destination path is possibly where it is failing the PhysicalName of the activemq queue is in this pattern 'abc.queue_name'.
I've tried the following destinations
/queue/abc/queue_name
/queue/abc.queue_name
abc.queue_name
Any suggestions are greatly appreciated.
Thanks
from stompclient import PublishClient
client = PublishClient('IP', 53680)
response = client.connect('defaultPassword', 'defaultUser')
reponse1 = client.send('/queue/abc/queue_name', 'bla')
time.sleep(5)
Have you checked the webconsole to see if your Queue was created by the send?
You should also try adding a request id onto the send and waiting for a response, this will ensure that the broker has enough time to get the sent data before you client code disconnects.
You might also want to check the Broker logs to see if any errors are logged or any security warnings in case the user doesn't have publish rights.
Added this property to the activemq.xml file and im now seeing messages on the queue via the web console.
<transportConnector name="stomp" uri="stomp://0.0.0.0:61613"/>

Setting password in IRC BOT written in C++

I'm trying to make an IRC Bot that will log in to an existing account (on QuakeNet), so the Q bot can grant him the operator rank. I can successfully log in to server with a proper nick, but I don't know how to make my bot actually log in to an account. Here is the code I use:
send(cSock, "PASS SuperPasswordOfAnAdmin\r\n", strlen("PASS SuperPasswordOfAnAdmin\r\n"), NULL);
send(cSock, "USER custom 0 0 SuperUsernameOfAnAdmin\r\n", strlen("USER custom 0 0 SuperUsernameOfAnAdmin\r\n"), NULL);
send(cSock, "NICK SuperNickOfAnAdmin\r\n", strlen("NICK SuperNickOfAnAdmin\r\n"), NULL);
And it doesn't seems to work properly. Does anybody know what should I do?
Thanks in advance for any replies.
I would suggest using a client like XChat and manually performing the steps that you're trying to have the bot automate and watching the raw log window. This will show you the commands that are being executed by your client, and anything the server is sending that you'll need to wait on or respond to.
Note that when you're looking at the commands in the QuakeNet documentation, these are client commands, not the actual IRC commands that are sent to the server. For instance, /msg user message here is actually sent over the wire as PRIVMSG user :message here.
I suspect you will have to do somewhat more than what your initial code suggests in order to properly satisfy the IRC server, like handling PING/PONG and waiting for the 001 numeric. In pseudocode:
// connect
conn := Connect("tcp", "your.irc.server:6667")
// login
Fprintf(conn, "PASS %s\r\n", server_password)
Fprintf(conn, "USER %s . . :%s\r\n", username, realname)
Fprintf(conn, "NICK %s\r\n", nick)
forever {
line := ReadLine(conn)
command, args := ParseIRCLine(line)
// welcome message, we're in!
if command == "001" {
break
}
// PING, send PONG
if command == "PING" {
Fprintf(conn, "PONG :%s\r\n", Join(args, " "))
}
}
Fprintf("PRIVMSG Q#CServe.quakenet.org :AUTH %s %s\r\n", username, password)
// wait for response from Q
// join channels, etc
// handle more pings, channel messages, etc
Usually IRC servers have a service called NICKSERV which allows you to identify your account:
You specify the following command:
/nickserv identify [nickname] password
So in your C++ program you would have to send:
send(cSock, "NICKSERV IDENTIFY SuperNickofAnAdmin SuperPasswordOfAnAdmin");
For QBOT you can do:
/msg Q#CServe.quakenet.org AUTH username password
So in your C++ program you send:
send(cSock, "MSG Q#CServe.quakenet.org AUTH SuperNickofAnAdmin SuperPasswordOfAnAdmin");
To grant the user operator status on IRC you will have to send the command:
MODE #Channel +o username
+o is the operator status and will display the '#' before the user's alias.
You can use a telnet client to speak directly with the server. This will require you to use all of the behind-the-scenes commands, which may help familiarize you with the required I/O needed for a running bot.
Source is the top rated answer on this question: How do i program a simple IRC bot in python?

Exchange Web Services, try to use ExchangeImpersonationType

I am trying to use EWS, first time trying to use the ExchangeServiceBinding. The code I am using is below:
_service = new ExchangeServiceBinding();
//_service.Credentials = new NetworkCredential(userName, userPassword, this.Domain);
_service.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
_service.Url = this.ServiceURL;
ExchangeImpersonationType ei = new ExchangeImpersonationType();
ConnectingSIDType sid = new ConnectingSIDType();
sid.PrimarySmtpAddress = this.ExchangeAccount;
ei.ConnectingSID = sid;
_service.ExchangeImpersonation = ei;
The application is an aspnet 3.5 trying to create a task using EWS. I have tried to use impersonation because I will not know the logon user's domain password, so I thought impersonation would be the best fit. Any thoughts on how I can utilize impersonation? Am I setting this correctly, I get an error while trying to run my application. I also tried without impersonation just to try to see if I can create a task, no luck either. Any help would be appreciated. Thanks.
Without broader context of your code snip, I can't tell for sure what's wrong, but here are a few things you might find useful...
You mention you had trouble connecting without impersonation.
I'm assuming you are using Exchange Server 2007 SP1, yes?
Do you have a mailbox for which you do know the username and password? If so, consider trying to connect to that mailbox, just to see if you can send an email or query for inbox count. That will help verify your connection at least.
As to exchange impersonation,
have the permissions been set on the Client Access Server (CAS) to enable impersonation?
Have the permissions been set on either the mailbox or mailbox database (containing the mailbox you are attempting to access)?
are you in a cross-forest scenario that requires additional trust relationships?
If not, that might explain why you cannot connect.
Some links you might find useful
Configuring (http://msdn.microsoft.com/en-us/library/bb204095.aspx)
Using Exchange impersonation (http://msdn.microsoft.com/en-us/library/bb204088.aspx)
Access multiple resource mailboxes (http://msexchangeteam.com/archive/2007/12/13/447731.aspx)