KyleGobel / Hipchat-CS

An easy to use C# wrapper of the V2 Hipchat API
MIT License
46 stars 37 forks source link

Newbie Hipchat #26

Open kiquenet opened 8 years ago

kiquenet commented 8 years ago

Suggestion: working together with https://github.com/hugorodgerbrown/HipChat.net

Question: Can I use Hipchat and Powershell like Slash ?

https://gist.github.com/magnetikonline/11007e42d86f490b84f8

https://github.com/jgigler/Powershell.Slack/blob/master/Send-SlackMessage.ps1

http://geeks.ms/enterprise/2016/02/15/monitorizar-eventos-con-powershell/

function Send-SlackMessage([string]$message, [string]$userName, [string]$channel="#tests"){ $postSlackMessage = @{token="EL_TOKEN_SLACK_VIENE_AQUI";channel=$channel;text=$message;username=$userName;icon_url="ICONO.png"} $body = Invoke-RestMethod -Uri https://slack.com/api/chat.postMessage -Body $postSlackMessage -method Post }

$time=Get-Date $time=$time.addHours(-1) $section="Application" $errors = get-EventLog -LogName $section -EntryType Error -After $time -Source "Application Error"

$errors | foreach { $username=$env:computerName+": "+($.Source)+"(ID "+($.InstanceID)+")" write-host $username write-host "--------------------------------" write-host $.Message send-SlackMessage -message $.Message -userName $username -channel "#tests" }

KyleGobel commented 8 years ago

When I started this project the other implementation (https://github.com/hugorodgerbrown/HipChat.net) used the v1 api. This uses the v2 api.

Unfortunately though I'm in a similar situation as him.

The company I work for has switched to slack instead of hipchat, so I literally never use hipchat anymore, which makes adding things or changing things much harder.

I've never created powershell snap-ins before, but it's all .net I believe and would be pretty easy to call this library (or just use the raw REST API) from powershell.

I do not know how to do this off hand though :(