Ruby HipChat Wrapper, how to check that a username is valid? - ruby

I am using the ruby HipChat Wrapper to send HipChat messages with a script. Before attempting to send any messages I would like to be able to check that the users I am attempting to message exist and are valid.
Is there a function in the HipChat::Client class that allows me to do this?
Note: I know that I can test if a user exists by attempting to send a message. If the script exits with a Access denied to user error then it is invalid. However I would like to test that a user exists without actually sending any messages.

I'm not familiar with that client, however looking at the library you should be able to do something like this client.user('foo#bar.org').view (assuming API V2).
Have a look at user.rb#L57 which uses https://www.hipchat.com/docs/apiv2/method/view_user, that will probably give you back an error as well if the user does not exist (unsure). It's probably still better than sending the entire message before realising the user does not exist (alternatively you can also retrieve all users and check it against that).

Related

Slack slash command: Respond as user, not app

When sending the response to a Slack slash command, I would like to send it under the user that has launched the slach command.
I have created a Slack app with a slash command. It calls my Flask webservice and I use the "response_url" webhook to write something back to the channel. The response in the channel is given by my app. This works as expected. But I would like for the response to be displayed as if a user has given it.
An example would be the Slack plugin from giphy. If I call it, I get an ephemeral message to choose the gif I would like. But then it is posted in the channel under my name.
So I have 2 questions:
How does the API call look like to respond to the slash command as a specific user?
What permissions for my app are required to allow for such behaviour of the app?
The Slack API documentation is comprehensive, but much research didn't yield the result I wanted.
Thanks!
When you are using response_url, you can't customize your username or icon. For this, you'll need to use chat.postMessage API method. There are now two ways to achieve what you need here:
Use user token: This gives you access to take actions on the behalf of the user. Although, you'll need to take authorization from every user you want post the message as.
Request chat:write.customize scope with your bot token: You can post a message with icon_url and username parameters where you can provide the user's icon and name respectively for both the parameters. This is much easier, as this only requires one-time authorization.
More information in the official documentation.

Get user email in windows 10 universal app

I am trying to build a control that the user can use to send feedback to developer. I am using email as a delivery method and I leverage sendgrid email service for this. Now I want to know the users email address so I can respond back to the user's concern. I am not sure how to get the user's email in window 10. Any help or pointers please?
I would strongly recommend to use the sharing approach that has been introduced with Windows 8 - instead of writing and maintaining your own mail functionality and trying to access additional user data.
Have a look at the existing and built in e-mail functionalities. They make use of the user's connected mail accounts and the mail app. This way you don't need to worry about handling the message transmission or anything but rather hand the information over to the mail client. This way you also know how to reply back.
And as a bonus, the user can still access their message via the Sent Mails folder :)
There is a specific class for that, the EmailMessageClass (https://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.email.emailmessage.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1) as well as a dedicated guide with code example.
https://msdn.microsoft.com/en-us/library/windows/apps/mt269391.aspx
Essentially you can prepopulate the Mail fields with necessary app information where applicable. The user gets to choose which accounts he wants to send the mail from, but it will open in the mail client.

Sinch, presence info

Is there a way to get presence info of each sinch user (sinch sdk, user online/offline)?
for example, I would not want to make a voip call to somebody who is not online currently,
cause it takes too much time for Sinch to find out whether the call can be made or not.
Currently, it is not possible to query for a user's capabilities before placing a call. Instead, an error specifying the user has no call capability will be returned when calling that particular user.

Sending XMPP message to offline Google Talk user with ruby xmpp4r

When using Perl's Net::Jabber, sending a simple message to an offline user causes the message to be delivered to the user when he comes online (it even show's in the user's gmail account as unread messages). That's as simple as doing
my $msg = Net::Jabber::Message->new();
$msg->SetMessage(...);
$connection->Send($msg);
In Ruby xmpp4r, doing the same equivalent thing does not send the message to an offline user, instead returning (async) a xmpp service-unavailable stanza or even not returning anything, and also not working. Message is simply lost.
How can one send an offline message with xmpp4r?
Also, in related subject, in xmpp's api docs for Jabber::Stream's send method, there is a "block" parameter. How does one use that?
Thanks
Make sure that you're doing type=:chat on the message.
client.send(Jabber::Message.new(jid, contents).set_type(:chat))
(code copied from Ricardo Pardini's comment, for long-term clarity)

How does who-has-blocked-me-on-msn sites work?

I understand that this isn't actually possible. So... what do the do? Can a program retrive a list of msn contacts using a valid user/password?
I think there is/was a vulnerability in the MSN protocol that would allow the client to check if it was blocked. Its not fetching the user list of the blocked person. Not sure of the details, but its something along the lines of:
for every one of my contacts
try to send message
if server return status == blocked
return true
What they used to do was exploit the fact that you had to define who you had blocked on MSN for you not to be able to see their status. Then, they issued and update so that only users you allow can see your update. Previously, they'd simply try and IM the user and see if they were online.
Using the MSNPX protocol, yes. See www.hypothetic.org/docs/msn/

Resources