mirror of https://tildegit.org/ben/sedbot
add nickserv support
parent
0d43cf75b8
commit
b0063db78e
|
@ -1,3 +1,4 @@
|
||||||
.cfg
|
.cfg
|
||||||
sedbot.err
|
sedbot.err
|
||||||
sedbot.log
|
sedbot.log
|
||||||
|
account.ini
|
||||||
|
|
28
README.md
28
README.md
|
@ -1,9 +1,30 @@
|
||||||
sedbot
|
# sedbot
|
||||||
======
|
|
||||||
|
forked from [clsr/sedbot](https://github.com/clsr/sedbot) -
|
||||||
|
updated for `-i`'s new argument requirement and daemonized
|
||||||
|
|
||||||
sedbot is an IRC search-replace bot written using bash and sed.
|
sedbot is an IRC search-replace bot written using bash and sed.
|
||||||
|
|
||||||
Usage: Edit the settings on top of sedbot.bash and run it under an unprivileged user.
|
### usage
|
||||||
|
|
||||||
|
1. `cp .cfg{.example,}`
|
||||||
|
1. adjust as needed
|
||||||
|
1. `bash sedbot.bash`
|
||||||
|
|
||||||
|
### daemonization
|
||||||
|
|
||||||
|
1. adjust sedbot.service
|
||||||
|
1. `mkdir -p ~/.config/systemd/user`
|
||||||
|
1. `cp sedbot.service ~/.config/systemd/user/`
|
||||||
|
1. `systemctl --user daemon-reload`
|
||||||
|
1. `systemctl --user enable --now sedbot`
|
||||||
|
|
||||||
|
### authenticate to services
|
||||||
|
|
||||||
|
1. `cp account.ini{.sample,}`
|
||||||
|
1. fill in your credentials
|
||||||
|
1. restart the bot (`systemctl --user restart sedbot`)
|
||||||
|
|
||||||
|
|
||||||
Only the s command and g and i flags are supported. Multiple regular expressions can be used at once, delimit them with spaces in between the flags and the s next one's s command. The last one may omit the trailing / if it has no options.
|
Only the s command and g and i flags are supported. Multiple regular expressions can be used at once, delimit them with spaces in between the flags and the s next one's s command. The last one may omit the trailing / if it has no options.
|
||||||
|
|
||||||
|
@ -24,3 +45,4 @@ Example usage in chat:
|
||||||
<sedbot> <foo> gfhi
|
<sedbot> <foo> gfhi
|
||||||
|
|
||||||
Note that the bot uses the standard grep (POSIX) regular expressions, i.e. use `.\+` and `\(foo\)\?` instead of `.+` and `(foo)?` as you'd do in egrep or other regex engines. Backreferences are written like `s/\(.\)/\1`, where `\1` matches the first capturing group. [Read more about sed regular expressions.](https://www.gnu.org/software/sed/manual/html_node/Regular-Expressions.html)
|
Note that the bot uses the standard grep (POSIX) regular expressions, i.e. use `.\+` and `\(foo\)\?` instead of `.+` and `(foo)?` as you'd do in egrep or other regex engines. Backreferences are written like `s/\(.\)/\1`, where `\1` matches the first capturing group. [Read more about sed regular expressions.](https://www.gnu.org/software/sed/manual/html_node/Regular-Expressions.html)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
account=bensbots
|
||||||
|
password="my super secret password"
|
|
@ -3,7 +3,14 @@
|
||||||
#license: GNU GPL v3+
|
#license: GNU GPL v3+
|
||||||
|
|
||||||
# source configs
|
# source configs
|
||||||
. .cfg
|
if [[ -f .cfg ]]; then
|
||||||
|
. .cfg
|
||||||
|
else
|
||||||
|
printf "configs not found\n"
|
||||||
|
printf " cp .cfg.example .cfg\n"
|
||||||
|
printf "adjust settings and restart\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
exec 4> >(tee -a -- "$IRC_LOG") 2> >(tee -a -- "$ERROR_LOG" >&2)
|
exec 4> >(tee -a -- "$IRC_LOG") 2> >(tee -a -- "$ERROR_LOG" >&2)
|
||||||
|
|
||||||
|
@ -29,6 +36,14 @@ connect() {
|
||||||
sendmsg MODE "$NICK +B"
|
sendmsg MODE "$NICK +B"
|
||||||
if (($?)); then
|
if (($?)); then
|
||||||
return $?
|
return $?
|
||||||
|
fi
|
||||||
|
# log in to services account if we have configs
|
||||||
|
if [ -f account.ini ]; then
|
||||||
|
. account.ini
|
||||||
|
sendmsg SQUERY "NickServ IDENTIFY ${account} ${password}"
|
||||||
|
if (($?)); then
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@ After=sedbot.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
WorkingDirectory=/home/bot/sedbot
|
WorkingDirectory=/home/ben/workspace/sedbot
|
||||||
ExecStart=/home/bot/sedbot/sedbot.bash
|
ExecStart=/bin/bash sedbot.bash
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=5
|
RestartSec=5
|
||||||
StartLimitInterval=60s
|
StartLimitInterval=60s
|
||||||
|
|
Loading…
Reference in New Issue