Skip to content

Instantly share code, notes, and snippets.

@donpdonp
Last active June 30, 2023 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donpdonp/4771db49f15257a573a19cea790c3668 to your computer and use it in GitHub Desktop.
Save donpdonp/4771db49f15257a573a19cea790c3668 to your computer and use it in GitHub Desktop.
(function() {
setup()
return {name:"ai"}
})
var sessionKey
function setup() {
}
function go(msg){
if(msg.method == "irc.privmsg") {
var match = /^\!ai(\s+(.+))?$/.exec(msg.params.message)
if(match) {
if(!sessionKey) {
sessionKey = session_key()
bot.say(msg.params.channel, "new session key "+sessionKey)
}
}
}
}
function session_key() {
var url = 'https://pi.ai/api/chat/start'
var params = { url: url, headers: {"Content-Type": "application/json"} }
var body = {}
var data = http.post(params, body);
bot.say(bot.admin_channel, JSON.stringify(body))
return data
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment