-
Notifications
You must be signed in to change notification settings - Fork 4
Send messages from PowerShell -> Bot -> IRC channel #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Send messages from PowerShell -> Bot -> IRC channel #10
Conversation
A helper script to allow sending messages to an IRC channel via the bot.
Code to keep a local asynchronous Named Pipe open. Regularly check it to see if there's any text in it, with a call in the main loop. Read any text from it, and write it to the (first) IRC channel the Bot is connected to. Close/dispose the pipe at the end of the script.
Thank you for this new feature! It's a great idea. I hope to do an in-depth review later this week when I'm a little less busy. Here's some quick feedback:
Thanks again! |
Those are good questions and right now it won't handle any of those things - and I would rather download single file than a module. I'm rethinking it, and came up with:
Does that sound usable? (I haven't tried to write this yet). |
I like your suggestion. Using HTTP opens the possibility of many languages and toolkits being able to easily interface with the PS bot. Also, it makes it cross-platform, since PS is now also on Linux. I would like to make your proposal a bit more generic. Why not have an command-line switch on Run-IrcBot that starts an HTTP server and listens for connections? On every HTTP GET/POST, we grab a JSON object and pass it into the bot as a This way, bots can decide what to do with their connection. Your bot would unpack the message string and the channel name and send a custom Perhaps we can start with that and see where that takes us. What do you think? |
I was avoiding full HTTP because I don't know of any good way to implement it; the ways I found were:
Do you know of another approach? That's why I came to the idea of a very basic TCP listener which would look for a JSON dictionary in incoming data. That way a HTTP client could be misused to call it for convenience, but it wouldn't be a full stack. However, it could be a basis for building into a more complete HTTP server - but that might be tied in with the issue of the bot being single threaded. |
Gotcha. I like your idea. Let's go for it. TCP listener it is. We should at least provide the URL that was in the Optionally, we can parse HTTP pretty readily by splitting on the colon. The HTTP syntax is actually pretty simple: a header line, a bunch of colon-delimeted lines, a blank line, and the payload. JSON is fine with me. I'm interested in the biggest bang with the a minimal amount of code. The reason I like all this is because a TCP listener must be managed by the parent script because the bot script goes away on every request. I will accept a pull request for this. 😄 |
This pull request adds a way to send text from a PowerShell session, through the bot, and out to IRC.
The main change is to Run-IrcBot.ps1, adding a function to keep a named pipe listener running, asynchronously in the background, and a call inside the main loop to process it.
And there's a helper script, and an update to the readme to give examples.