Skip to content

A 'linkme'-like bot for /r/ArchLinux

I was inspired by this post a few moths ago to make a Linkme bot for /r/ArchLinux, but not only for the AUR like /u/tvgdb suggested, but for the official packages and wiki too.

Two days ago I found my old version of the code, so I decided to refurbish it and actually make it work, and now it is (hopefully) ready.

What is a linkme bot?

A linkme bot parses the comments of a subreddit and replies to certain comments that contain certain syntax, indicating that the bot should respond. The response is contains a link and possibly some information on the subject.

How to use?

Your comment has to contain some text to match this regex: (?:^|[\s,.!?,-])(aur|pac|wiki)/([\w@+.\-]+)(?:$|[\s,.!?,]). ( (aur|pac|wiki)/([\w@+.\-]+) is the important part. )

type/name

The first part indicated where to search (aur, pac [pacages] or wiki), followed by a '/' and the name of the package or the article.

The characters before and after have to either whitespaces or non-existant.

Arch wiki links are automatically parsed.

You can mention more than one package/page in one comment, all should be mentioned.

Invocation examples:

Valid:

I use aur/atom-editor and pac/vim


pac/coreutils


check out wiki/pacman for more information

Invalid:

This is cool **pac/emacs** ( The starts are not whitespaces )


wik/fef (wik is not valid)

Is it currently running?

Yes, finally I was able to fix it, and make it run on heroku.


Please contact me if you have any problems with this bot, it's still in testing.

Help me get karma (better commenting): http://redd.it/2sngvs

Contact: /u/SurviAvi

Source: https://gist.github.com/phikal/7fbee4ba03366cf7a704

Edited 29 Mar 2015. We only hold this version.

43 points20 comments
Open on Reddit
About this post
Posted
Archived
Edited
Score
43 · 100% up
Kind
Text
ID
2snl5x

Author

1
posts
60
comments
0
media
View profile

57 comments

Awesome! Testing this with aur/qutebrowser

2 points
unknown author

Deleted before we saved it.

1 points
unknown author

Deleted before we saved it.

1 points

This broke in https://www.reddit.com/r/archlinux/comments/2sq70e/python_shell/cnruukj where it thought https://en.m.wikipedia.org/wiki/IPython was a link to an archlinux wiki page, which it obviously is not. You problably want to change https://gist.github.com/phikal/271374cf5eee9c659c7f#file-allb-py-L74

find = re.compile(r'\s?(aur|pac|wiki)/([a-zA-Z0-9@+._\-]+)\s?')

to

find = re.compile(r'\s+(aur|pac|wiki)/([a-zA-Z0-9@+._\-]+)\s?')

so the regular expression really only matches if aur/pac/wiki is preceded by whitespace (untested).

/edit: Your current regex also matches This is cool **pac/emacs** which you list as an invalid example.

2 points

I'm working on that already, and thanks for the suggestion.

I'm thinking of using something in the direction of

find = re.compile(r'\s*(aur|pac|wiki)/([a-zA-Z0-9@+._\-]+)\s*')

with * instead of +, since whitespaces are not neccecary, but the other option besides no spaces at all. It's still not working, but thansk again for the support.

1 points

\s* has exactly the same problem as \s? which is that it can match 0 or more (or 1 in case of ?) repititions of whitespace.

1 points
unknown author

Deleted before we saved it.

1 points
unknown author

Deleted before we saved it.

1 points

pac/coreutils

2 points
unknown author

Deleted before we saved it.

2 points
unknown author

Deleted before we saved it.

1 points
unknown author

Deleted before we saved it.

1 points

I completely forgot about that post, great you made a working version!

2 points

Is it running right now? Either way, once you've got it all worked out, it looks pretty sweet. Testing:

aur/toilet

1 points
unknown author2 hidden

Deleted before we saved it.

1 points
unknown author

Deleted before we saved it.

1 points
unknown author

Deleted before we saved it.

1 points
unknown author1 hidden

Deleted before we saved it.

1 points
unknown author

Deleted before we saved it.

2 points
unknown author3 hidden

Deleted before we saved it.

1 points
unknown author

Deleted before we saved it.

1 points
unknown author

Deleted before we saved it.

1 points
unknown author

Deleted before we saved it.

1 points
unknown author2 hidden

Deleted before we saved it.

1 points
unknown author

Deleted before we saved it.

1 points
unknown author

Deleted before we saved it.

1 points
unknown author2 hidden

Deleted before we saved it.

1 points
unknown author

Deleted before we saved it.

1 points
unknown author

Deleted before we saved it.

1 points
unknown author2 hidden

Deleted before we saved it.

1 points
unknown author

Deleted before we saved it.

1 points
unknown author

Deleted before we saved it.

1 points
unknown author

Deleted before we saved it.

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.