Skip to content

Code52/jibbr

Repository files navigation

JibbR

A Jabbr bot designed for collaborative projects

Extending the Jabbot library - a bot API for JabbR.

Connecting to a Jabbr Room

It's as easy as:

varbot=newBot("http://myjabbot","username","password");bot.PowerUp();bot.Join("someroom");bot.Say("Hello","someroom");bot.Say("Ok I'm off");bot.ShutDown();

Writing Sprockets

Sprockets are things you can plug-in to enhance the behavior of your bot. Simply drop a dll with classes that implement ISprocket into a Sprockets folder and you're done. Here's an port of the math.coffee from hubot:

publicclassMathSprocket:RegexSprocket{publicoverrideRegexPattern{get{returnnewRegex("(calc|calculate|convert|math)( me)? (.*)");}}protectedoverridevoidProcessMatch(Matchmatch,ChatMessagemessage,Botbot){varclient=newHttpClient();client.DefaultRequestHeaders.AcceptLanguage.Add(newStringWithQualityHeaderValue("en-us"));client.DefaultRequestHeaders.AcceptCharset.Add(newStringWithQualityHeaderValue("utf-8"));client.GetAsync("http://www.google.com/ig/calculator?hl=en&q="+Uri.EscapeDataString(match.Groups[3].Value)).ContinueWith(task =>{if(task.Result.IsSuccessStatusCode){task.Result.Content.ReadAsStringAsync().ContinueWith(readTask =>{dynamicjson=JsonConvert.DeserializeObject(readTask.Result);stringsolution=json.rhs;bot.Reply(message.FromUser,solution??"Could not compute.",message.Room);});}});}}

A new extension being added to JibbR is for announcement-style sprockets. You can specify how often an announcement may occur, and include code to execute for the active bot.

publicclassEchoAnnouncement:IAnnounce{publicTimeSpanInterval{get{returnTimeSpan.FromMinutes(10);}}publicvoidExecute(Botbot){foreach(varroominbot.Rooms){bot.Say("Hello world!",room);}}}

another code52 project

code52.org

=======

About

A Jabbr bot designed for collaborative projects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 9

Languages