CodeWalrus

Featured Member Projects => Completed and Inactive Projects => [Completed] CodeWalrus Tools (Web/Android/PC) => Topic started by: Yuki on December 17, 2014, 11:03:21 PM

Title: YukiBot
Post by: Yuki on December 17, 2014, 11:03:21 PM
It's our post notifier bot I just wrote, along with a few features I should probably write (based on Eeems' EeeZorBot framework).

Features
- Notifies of posts made on CodeWalrus
- Provides services to the IRC channels

How it works

The forum software simply sends an UDP packet to the bot which posts it on IRC. Probably the simplest and the fastest way so it won't lag at all. I chose UDP because it's a connectionless protocol, unlike TCP.

Restart

Should you have the need restart it (which I doubt), it's pretty much the same way as OmnomIRC (it could probably be converted as a systemd service if you want). Look for something like "js lib/main.js" or "npm start", kill it, cd to where the bot is (currently in my homedir) and type "npm start" in a screen.

Code
If you guys want to write a mod, I'll post the current diff here:

--- Subs-Post.php~ 2014-12-17 21:38:52.494808188 +0000
+++ Subs-Post.php 2014-12-19 01:14:23.910808189 +0000
@@ -2032,6 +2032,15 @@
if ($msgOptions['approved'])
updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0);

+ // Send this to IRC
+ if(!in_array($topicOptions['board'], array(2, 12)))
+ {
+        $ircsocket = stream_socket_client('udp://127.0.0.1:33333');
+        $sendstr = "PRIVMSG #CodeWalrus :\x0310New ".($new_topic?"topic":"post")." by \x0304".html_entity_decode($posterOptions['name'])."\x0310 on \x0303".html_entity_decode($msgOptions['subject'])."\x0310 http://codewalr.us/".$topicOptions['id']."/".$msgOptions['id'];
+        stream_socket_sendto($ircsocket, $sendstr);
+        fclose($ircsocket);
+ }
+
// Alright, done now... we can abort now, I guess... at least this much is done.
ignore_user_abort($previous_ignore_user_abort);


The diff is for both /Sources/Subs-Post.php and /mobiquo/include/Subs-Post.php (because Tapatalk copied the file in its own directory or I dunno).

For the bot plugins I added, it's here: https://github.com/juju2143/EeeZorBot-scripts

Current bugs
- Doesn't hide the staff board
- Tapatalk fixed!
- No customization other than modifying the code directly
- No topic length limit (it probably shouldn't be annoying but we can always add it if it's a problem, just tell me)
- Some commands are still experimental and can crash the bot

Have fun. :P
Title: Re: YukiBot
Post by: Dream of Omnimaga on December 18, 2014, 07:00:04 AM
Ok thanks for the tip. It should make it easier to upgrade until we get a mod of this. :)

I doubt topic lenght should be an issue, because of the short URLs.


I think nicknames should be made color-less or medium gray, though (there's an IRC character for that that is not black), because right now it might look too much like a ripoff of Omnimaga post notifications (we use the same color scheme). Green is fine, though, because the site mainly uses green anyway)
Title: Re: YukiBot
Post by: novenary on December 18, 2014, 12:20:58 PM
Hmmm nice. You might wanna consider moving it to freenode though once we have a better botnet.
Title: Re: YukiBot
Post by: Yuki on December 18, 2014, 03:03:35 PM
It should connect to all three networks, but I still have to figure out why it's not connecting to Omninet and Freenode. Once it's figured out the post notifier will move to Omninet.
Title: Re: YukiBot
Post by: Dream of Omnimaga on December 18, 2014, 05:43:59 PM
Good luck juju x.x
Title: Re: YukiBot
Post by: novenary on December 18, 2014, 06:56:16 PM
Ah ok that's cool. :)
Title: Re: YukiBot
Post by: Yuki on December 19, 2014, 03:15:19 AM
She's on all three networks now. Also, if you want me to implement some features to her, like Google/DDG/CodeWalrus search, output the title of an URL or even improvments to the post notifier, please tell me and I'll try to work on them over the Xmas vacations.
Title: Re: YukiBot
Post by: pimathbrainiac on December 19, 2014, 03:38:29 AM
Yay it works!

Should I take WalTopic down now?
Title: Re: YukiBot
Post by: Dream of Omnimaga on December 19, 2014, 03:52:25 AM
Keep a copy in case we ever have major issues with the bot we got right now, though.
Title: Re: YukiBot
Post by: aetios on December 19, 2014, 07:48:11 AM
Why not name it YuukiBot as a reference to SAO2 :P
Title: Re: YukiBot
Post by: Dream of Omnimaga on December 19, 2014, 12:05:59 PM
Ideally it should be named CodeWalrus or ^New and the post notifications made so that they use the /me command, so that way they are shorter. Eg they should probably look like this:

* CodeWalrus post by DJ Omnimaga in Walrification begins monday! http://codewalr.us/56/1946
Title: Re: YukiBot
Post by: Yuki on December 19, 2014, 03:24:17 PM
Quote from: aeTIos on December 19, 2014, 07:48:11 AM
Why not name it YuukiBot as a reference to SAO2 :P
Because it's a reference to Haruhi Suzumiya. (And because I mostly always use Yuki as a character name, but yeah, Haruhi.)

Quote from: DJ Omnimaga on December 19, 2014, 12:05:59 PM
Ideally it should be named CodeWalrus or ^New and the post notifications made so that they use the /me command, so that way they are shorter. Eg they should probably look like this:

* CodeWalrus post by DJ Omnimaga in Walrification begins monday! http://codewalr.us/56/1946
That's an idea.
Title: Re: YukiBot
Post by: novenary on December 21, 2014, 09:15:17 PM
Hmmm does it sync topics (with omnom too) ? Cause iirc omnom topic syncing doesn't work.
Title: Re: YukiBot
Post by: Dream of Omnimaga on December 21, 2014, 09:58:18 PM
If you mean the /topic command, then it won't sync unless the bot has ops in the channel. But again maybe it's broken. :P
Title: Re: YukiBot
Post by: Yuki on December 22, 2014, 07:05:42 AM
It's on GitHub! Also new page title thingy.

https://github.com/juju2143/EeeZorBot-scripts
Title: Re: YukiBot
Post by: Dream of Omnimaga on December 22, 2014, 12:18:38 PM
I see EeeZor in the title, which is Eeems-related. Did you use any code of his in this bot and did you ask him permission before re-using it? I don't want to have the same issues as with the recent posts mod.
Title: Re: YukiBot
Post by: Yuki on December 22, 2014, 04:05:54 PM
He strongly encourages the use of his framework for my IRC bot needs, and I did not modified anything other than the config (I update it once in a while) and my own plugins I dumped in the scripts folders using his API, so I guess it's okay? He probably still doesn't know it's used on the CodeWalrus channel, though. Should probably tell him next time I see him. Pretty sure he'd be happy I'm writing code for it anyway.
Title: Re: YukiBot
Post by: Dream of Omnimaga on December 22, 2014, 05:19:25 PM
I guess it probably depends of the license and who made it. Considering you are contribiting to it it should prbly be fine, tho.
Title: Re: YukiBot
Post by: Yuki on December 22, 2014, 11:26:28 PM
The bot now have a search engine! Use .cw <search query>.
Title: Re: YukiBot
Post by: pimathbrainiac on December 22, 2014, 11:53:15 PM
Yay now for ddg search (since the stupid google API is gone)
Title: Re: YukiBot
Post by: Yuki on December 23, 2014, 12:44:47 AM
DDG search is not implemented yet. That one uses MySQL.
Title: Re: YukiBot
Post by: Dream of Omnimaga on December 23, 2014, 04:48:30 AM
Would there be a workaround for Google?
Title: Re: YukiBot
Post by: Yuki on December 23, 2014, 05:19:17 AM
Yep. And it's already implemented. \o/

So far:
.cw: Searches posts on CodeWalrus (uses some obscure function in MySQL)
.google: Google Search (does not use the API!)
.calc: Calculator! (Uses Wolfram Alpha's API)

Also:
<Yuki> .calc the game
<YukiBot> [calc] You just lost.
Title: Re: YukiBot
Post by: Dream of Omnimaga on December 23, 2014, 12:04:09 PM
Cool to hear. You should probably make a topic elsewhere on the forum that other people can see that documents the Google trick in case other members would like to fix their respective bots. I am curious about what workaround was used as well.
Title: Re: YukiBot
Post by: pimathbrainiac on December 23, 2014, 03:15:23 PM
That's really cool and also document that google trick so I can steal your code but in Java for my bot on ##FRC on Freenode.
Title: Re: YukiBot
Post by: Yuki on December 23, 2014, 05:28:04 PM
In short it just scrapes the webpage for results.

https://github.com/jprichardson/node-google
Title: Re: YukiBot
Post by: Dream of Omnimaga on December 23, 2014, 05:29:13 PM
Wait what does it screen the entire CW website in order to find results? O.O I hope you meant Google page, else the bandwidth usage...
Title: Re: YukiBot
Post by: Yuki on December 23, 2014, 05:31:20 PM
Yeah I meant Google. For CW it queries the MySQL server.
Title: Re: YukiBot
Post by: Dream of Omnimaga on December 23, 2014, 05:32:36 PM
Oh ok phew lol.

Also should this topic be moved to public? (you could always create another topic in the staff board or update pimath's topic on how to restart the bot when needed)
Title: Re: YukiBot
Post by: Yuki on December 23, 2014, 05:34:19 PM
Yeah I guess. Wasn't sure since it contains some instructions to the staff, but nothing inportant. Should prolly move those infos in another topic.
Title: Re: YukiBot
Post by: Dream of Omnimaga on December 23, 2014, 07:54:00 PM
Yeah I thought it would actually be best to have all the bot restart and SMF code change info in one topic so it's easier to find. We only have two minor code changes, but losing track of them would make it very hard to upgrade in the future. And knowing how to restart the bots would be nice since sometimes Omninet and EFnet crap themselves out, causing most bots to disconnect.
Title: Re: YukiBot
Post by: Dream of Omnimaga on December 24, 2014, 08:13:49 AM
Juju: Fix, pl0x.

Quote03:12:17 <@WalriiBot> (O)* DJ_Omnimaga has changed the topic to Hangout for http://codewalr.us fans (TI-84+, Nspire, HP Prime, Mobile, Music and Art board) | Rules http://codewalr.us/36 | Last week of privateness! (Opening Jan 1st 2015) | https://www.facebook.com/CodeWalrusFans | https://twitter.com/codewalr_us
03:12:17 @WalriiBot set the topic: Hangout for http://codewalr.us fans (TI-84+, Nspire, HP Prime, Mobile, Music and Art board) | Rules http://codewalr.us/36 | Last week of privateness! (Opening Jan 1st 2015) | https://www.facebook.com/CodeWalrusFans | https://twitter.com/codewalr_us
03:12:17 <@WalriiBot> (E)<YukiBot> [title] Login
03:12:17 <@WalriiBot> (E)<YukiBot> [title] Login
03:12:18 <@WalriiBot> (E)<YukiBot> [title] Login
03:12:18 <@WalriiBot> (E)<YukiBot> [title] Login
03:12:27 <@WalriiBot> (O)<DJ_Omnimaga> fail
Title: Re: YukiBot
Post by: Yuki on December 24, 2014, 08:20:38 AM
This is actually the expected behavior. You posted 4 URLs in the same line, it posted 4 times the title. Although the titles for the Facebook and Twitter pages shouldn't probably say "Login"...

EDIT: Well, stupid me. It was actually a bug. It's fixed now.

EDIT2: Wait, nope. This is pretty weird.

Quote from: IRCYuki   Hangout for http://codewalr.us fans (TI-84+, Nspire, HP Prime, Mobile, Music and Art board) | Rules http://codewalr.us/36 | Last week of privateness! (Opening Jan 1st 2015) | https://www.facebook.com/CodeWalrusFans | https://twitter.com/codewalr_us
YukiBot   [title] Login
YukiBot   [title] Login
YukiBot   [title] Update Your Browser | Facebook
YukiBot   [title] Update Your Browser | Facebook
Yuki   https://www.facebook.com/CodeWalrusFans | https://twitter.com/codewalr_us
YukiBot   [title] Update Your Browser | Facebook
YukiBot   [title] Update Your Browser | Facebook
Yuki   https://twitter.com/codewalr_us
YukiBot   [title] CodeWalrus (@Codewalr_us) | Twitter
Yuki   what
Yuki   https://twitter.com/codewalr_us https://www.facebook.com/CodeWalrusFans
YukiBot   [title] Update Your Browser | Facebook
YukiBot   [title] Update Your Browser | Facebook
Title: Re: YukiBot
Post by: Dream of Omnimaga on December 24, 2014, 05:14:25 PM
To be honest I don't like this feature much if it's gonna spam everytime we post URLs. Youtube, Cemetech, CW (perhaps Omni too if they ever get rid of PrettyURL for new topics) and some other page link descriptions are fine but I think it should either just detect the first link or put the description in one line. Not to mention when many links are posted this will become a mess anyway.
Title: Re: YukiBot
Post by: Yuki on December 25, 2014, 12:05:40 AM
Well I can always limit it to the first link if it's too annoying.
Title: Re: YukiBot
Post by: Dream of Omnimaga on December 25, 2014, 01:39:47 AM
The other idea would be to make it so it merges 2-4 descriptions at a time into one line (depending of how long they are).


Also we need a way to get the staff to use IRC more because right now they are very active on Telegram but not IRC. Either find an OmnomIRC alternative, such as modifying SimplePortal shoutbox then making a bot to relay IRC to the site and vice-versa, port SAX to SMF (independent from #cemetech of course, so that we can use our own rules) or find a way to get rid of ISP-specific Omnom lag (which isn't likely, seeing as even Omnimaga has lag too, from time to time).

Or we could get a bot to relay the Telegram channel to IRC, if that's not against Telegram rules, and encourage staff to use the staff board for site issues. The latter option would also show post notifications on Telegram, which might give Street some incentive to post on weekends instead of spending 24 hours straight customizing one of his 79 tablets and phones.  :P
Title: Re: YukiBot
Post by: novenary on December 25, 2014, 06:37:59 PM
Hmmm btw, I thought about posting this : I can't filter yukibot highlights like I do with new in #omnimaga because I'm on freenode and muting her highlights means muting every highlight coming from omnom/efnet/omninet. It'd be cool to make omnom not relay her messages and have her post on each network instead.
Title: Re: YukiBot
Post by: Dream of Omnimaga on December 26, 2014, 12:55:44 AM
Personally I'm against disallowing post notifications on OmnomIRC. If we get a working shoutbox at one point this would defeat the point of having post notifications in the first place, as most of our users would use OmnomIRC, and it would reduce activity a lot.

What I think is that we should probably find a way to make Omnom not highlight when Yukibot posts or make it so that it intentionally misspells everyone's nickname (eg S t r e e t w a l r u s   instead of Streetwalrus).

I don't want to hurt CW activity just because one person is annoyed that the bot highlights him.


That said, I think the URL title feature should be put in a separate bot, though, so we can ignore both features separately.
Title: Re: YukiBot
Post by: novenary on December 29, 2014, 08:55:57 PM
I meant relaying across networks, not on the shoutbox.
Title: Re: YukiBot
Post by: Dream of Omnimaga on December 30, 2014, 06:08:01 AM
Ok but I would still like post notifications to show up everywhere.
Title: Re: YukiBot
Post by: novenary on December 30, 2014, 07:56:09 PM
I think you misunderstood me. I said that yukibot should handle cross network  herself instead of relying on omnom for that.
Title: Re: YukiBot
Post by: Dream of Omnimaga on December 31, 2014, 05:10:42 AM
Oh ok, I thought you wanted post notifications on on OmnomIRC removed entirely O.O (that's what the OmnomIRC /ignore command is for)
Title: Re: YukiBot
Post by: Dream of Omnimaga on March 10, 2015, 06:29:17 PM
Do you know when this bot will be back up on IRC? I don't know if Withg ZNC services will ever come back so it might be wise to move the bot elsewhere
Title: Re: YukiBot
Post by: Yuki on March 10, 2015, 10:02:18 PM
She's always been on the CW server, without a ZNC.
Title: Re: YukiBot
Post by: Dream of Omnimaga on March 11, 2015, 03:36:56 AM
Oh ok but any idea why it's not online right now or at least why it lacks ops on EFnet?
Title: Re: YukiBot
Post by: Dream of Omnimaga on March 18, 2015, 11:14:54 PM
Something is wrong with Yukibot. Everytime a new post is made it says the post page title >.<

*   Walrified post by Eiyeron on Re: Walrii fanart http://codewalr.us/38/7472   6:09:03 PM
YukiBot   [title] Walrii fanart   6:09:03 PM
*   Walrified post by Cumred_Snektron on Re: Walrii fanart http://codewalr.us/38/7473   6:09:38 PM
YukiBot   [title] Walrii fanart   6:09:38 PM
*   Walrified post by Streetwalrus on Re: Raspberry Pi based GameCube modchip http://codewalr.us/59/7474   6:16:11 PM
YukiBot   [title] Raspberry Pi based GameCube modchip   6:16:11 PM
*   Walrified post by Streetwalrus on Re: Librecalc is dead Big Frown http://codewalr.us/327/7475   6:17:54 PM
YukiBot   [title] Librecalc is dead Big Frown   6:17:54 PM
*   Walrified post by Streetwalrus on Re: Pi day! http://codewalr.us/320/7476   6:18:53 PM
YukiBot   [title] Pi day!   6:18:54 PM
*   Walrified post by Cumred_Snektron on Re: Librecalc is dead Big Frown http://codewalr.us/327/7477
Title: Re: YukiBot
Post by: Yuki on March 19, 2015, 01:51:51 AM
Must be because I moved Walrified to OmniNet.
Title: Re: YukiBot
Post by: Dream of Omnimaga on March 19, 2015, 01:52:27 AM
Ah that might explain it. It seems fixed now. Not that this was a serious issue, but if there are activity spikes this would have cluttered the chat very bad.
Title: Re: YukiBot
Post by: Duke "Tape" Eiyeron on March 19, 2015, 06:16:32 AM
Yeah but such a filter should be easy to do, right?
Title: Re: YukiBot
Post by: novenary on March 19, 2015, 11:17:57 AM
Yeah it was in place when the bots were on efnet.
Title: Re: YukiBot
Post by: Dream of Omnimaga on March 20, 2015, 04:56:27 AM
Ah right, it was because the bot was on a different side of our IRC channel. :P It probably just thought Walrified was WalriiBot :P
Title: Re: YukiBot
Post by: Dream of Omnimaga on July 16, 2015, 05:44:10 AM
Something that should probably be fixed:

(http://img.codewalr.us/topictitles.png)

As demonstrated above and I witnessed it in the past (although obviously not as exaggerated :P), YukiBot reporting the post title instead of topic title can lead to confusion.
Title: Re: YukiBot
Post by: alexgt on July 16, 2015, 01:53:48 PM
Hey look mineprime has a blue walrii ^.^ (the topic #404)

Yeah that was confusing for me but rarely do people change the post title
Title: Re: YukiBot
Post by: Unicorn on July 16, 2015, 02:10:27 PM
I only change it if something monumental happens. :P
Title: Re: YukiBot
Post by: alexgt on July 16, 2015, 05:52:12 PM
aka 1337 posts :P
Title: Re: YukiBot
Post by: Unicorn on July 16, 2015, 10:47:04 PM
Yes, just that once :P
Title: Re: YukiBot
Post by: Yuki on July 17, 2015, 02:22:22 AM
Yeah, you can do that, and I'd probably vote to make it stay that way, but you definitely shouldn't abuse it.
Title: Re: YukiBot
Post by: Unicorn on July 17, 2015, 04:09:23 AM
What I thought too. ;)
Title: Re: YukiBot
Post by: Dream of Omnimaga on July 17, 2015, 04:49:16 PM
That could work. It just gets a bit confusing sometimes. Also alexgt it wasn't the blue walrus but rather (http://codewalr.us/omnomirc_www/smileys/rainbowwalrii3b.gif)
Title: Re: YukiBot
Post by: alexgt on July 17, 2015, 06:39:16 PM
Oh, that one is better still :P
Title: Re: YukiBot
Post by: Unicorn on July 17, 2015, 08:00:44 PM
I think it could go a little faster, then be better :P
Title: Re: YukiBot
Post by: Dream of Omnimaga on July 17, 2015, 10:50:01 PM
Nah, because on some LCDs the motion blur would make it look like it is actually slower or not moving much :P.
Title: Re: YukiBot
Post by: Unicorn on July 17, 2015, 11:08:04 PM
Quote from: DJ Omnimaga on July 17, 2015, 10:50:01 PM
Nah, because on some LCDs the motion blur would make it look like it is actually slower or not moving much :P.
Like my kindle :P

The guy on fire in the other thread went about .5 miles per hour. :P