Last active
June 30, 2023 16:47
-
-
Save donpdonp/4771db49f15257a573a19cea790c3668 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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