Skip to content
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

Merge develop withmaster #364

Open
wants to merge 119 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
ee9d5a3
fix func_queue typehint
jesopo Aug 26, 2020
eec8d1a
actually fix typehint and you can only throw Exception inheritors
jesopo Aug 26, 2020
e51aeb1
"unpacking a string is disallowed"
jesopo Aug 26, 2020
c32e073
explicit support for dronebl type 19 (abused vpn)
jesopo Sep 8, 2020
b6e8f66
better dronebl descriptions, show category in all list descriptions
jesopo Sep 8, 2020
6d99a9f
support dnsbl TXT records
jesopo Sep 14, 2020
68939b7
update dnspython lib, use new .resolve
jesopo Sep 14, 2020
5c1942a
handle unknown Zen Spamhaus results
jesopo Sep 17, 2020
f7a1c12
add torexit.dan.me.uk to dnsbls
jesopo Sep 18, 2020
027b9d7
Add parameter checking so bitbot doesn't add a None webhook and break…
alyx Sep 23, 2020
dc7040f
Merge pull request #276 from alyx/master
jesopo Sep 23, 2020
09fc00b
fix !cmute +time
jesopo Sep 25, 2020
e50c4ec
add !karmawho <target> to see who gave karma to <target>
jesopo Sep 29, 2020
777c14b
sort karma reversed and by abs()
jesopo Sep 29, 2020
35ce974
Merge pull request #1 from jesopo/develop
examknow Oct 4, 2020
84aa7d1
add ban-enforce-max config option
examknow Oct 4, 2020
2d76365
Update ban_enforce.py
examknow Oct 5, 2020
26b2037
Merge pull request #279 from examknow/develop
jesopo Oct 5, 2020
09cfae7
github.py needs exports from git_webhooks
jesopo Oct 17, 2020
2f5d001
shorturl-any shouldn't need a server
jesopo Oct 17, 2020
c4c6fdd
support check_run.status as a category+[status]
jesopo Oct 17, 2020
a91c034
show PRs on check_run output where possible
jesopo Oct 18, 2020
d6c1bea
Merge branch 'master' into develop
jesopo Oct 28, 2020
aa4b5d9
Change example pronouns to neutral pronouns
attwater Nov 1, 2020
fcbeaf3
[Tweets] Fix tweet age calc for TZ!=UTC
fndax Nov 5, 2020
74da824
Merge pull request #285 from fndax/patch-2
jesopo Nov 5, 2020
8cc47a9
refuse setting location to timezones we can't understand
jesopo Nov 9, 2020
538d6ca
Merge branch 'master' into develop
jesopo Nov 18, 2020
b3dc46a
Merge pull request #289 from attwater/master
jesopo Nov 21, 2020
86520b3
Improve weather formatting
shreyasminocha Nov 26, 2020
2d39421
Merge pull request #290 from shreyasminocha/master
jesopo Nov 26, 2020
cb43a6a
RSS custom format (#286)
examknow Nov 28, 2020
b046c36
make karmawho work better
examknow Jan 11, 2021
1fe8cb6
make karmawho case insensitive
examknow Jan 11, 2021
a0d6e51
rm debug line
examknow Jan 11, 2021
7283a26
update lxml
jesopo Jan 14, 2021
97693aa
casefold nickname so sed-sender-only works with capital letters in ni…
xfnw Jan 17, 2021
3fa2034
add 'delserver' command (#297)
examknow Feb 6, 2021
5d2a386
Clarify which bitbotd -a options are optional (#263)
fndax Feb 6, 2021
37523c7
make that easier on the eyes
examknow Feb 6, 2021
a5f29ce
Update config.md
TehPeGaSuS Feb 12, 2021
47965f5
support {DATA} in tls-certificate and tls-key
jesopo Feb 12, 2021
c0810f8
update py cryptography lib to 3.3.2
jesopo Feb 12, 2021
422d309
Update bitbot_user.service
TehPeGaSuS Feb 12, 2021
8c8d362
Update rest_api.md
TehPeGaSuS Feb 12, 2021
bfb34a4
switch from check_run to check_suite for github webhooks
jesopo Feb 15, 2021
e645a32
handle /[/,`#]/ as sed delimeters
jesopo Feb 20, 2021
e2fbbc2
remove scrypt requirement, use hashlib.scrypt instead
jesopo Mar 7, 2021
fabb6d8
make no entries message more specific
examknow Mar 9, 2021
e5e9450
move highlight prevention before urls
examknow May 9, 2021
2951bfc
add !dig as alias of !dns
jesopo May 16, 2021
8f6799b
freenode is dead long live libera.chat
jesopo May 25, 2021
df331bb
weather.py: add kelvin unit
examknow May 25, 2021
81dd0d2
GitHub PRs: Correctly attribute PR authors
aaronmdjones May 30, 2021
43430c5
Merge pull request #316 from aaronmdjones/amdj/github-pr-attribution
jesopo May 30, 2021
6637a79
Bump lxml from 4.6.2 to 4.6.3 (#309)
dependabot[bot] May 31, 2021
7b1ad1e
Merge pull request #312 from examknow/patch-6
jesopo May 31, 2021
fc651d8
Merge pull request #306 from examknow/patch-5
jesopo May 31, 2021
94108f4
Merge pull request #298 from examknow/patch-4
jesopo May 31, 2021
219f126
bump feedparser to 6.0.2
examknow Jun 4, 2021
07fcbd6
fully support draft/bot spec
examknow Jun 12, 2021
3ef21e0
support `draft/react` spec
examknow Jun 12, 2021
e63729f
Merge branch 'develop' into patch-4
examknow Jun 25, 2021
01b05da
Merge pull request #302 from PeGaSuS-Coder/patch-4
examknow Jun 25, 2021
31838f4
Merge pull request #301 from PeGaSuS-Coder/patch-3
examknow Jun 25, 2021
0fa184d
Merge pull request #303 from PeGaSuS-Coder/patch-5
examknow Jun 25, 2021
b7e1cc9
quotes.py: allow opting out of quotes
examknow Jun 25, 2021
4311d86
handle lastfm tracks only having 1 tag
jesopo Jul 10, 2021
b9a77fc
Merge pull request #319 from jesopo/examknow/message-reactions
examknow Jul 22, 2021
29ca012
Merge pull request #318 from jesopo/bot-mode
examknow Jul 22, 2021
f3c8d86
ignore.py: fix permissions
examknow Jul 22, 2021
b71afea
ignore.py: should actually be `permission`
examknow Jul 22, 2021
027e27d
Delete ircv3_react.py (#330)
VShell Oct 6, 2021
e68af22
Add AS and hostname to geoip
JeDaYoshi Oct 18, 2021
2e5836a
Get IP from buffer on geoip too
JeDaYoshi Oct 18, 2021
37aa85e
Add ipinfo command
JeDaYoshi Oct 18, 2021
858b3db
Make ipinfo command more similar to geoip
JeDaYoshi Oct 18, 2021
d8ba18a
Add support for multiple endpoints in ipinfo, fixes
JeDaYoshi Oct 18, 2021
24e0733
additional fixes to ipinfo/geoip
JeDaYoshi Oct 18, 2021
9ff4c23
Update apache2
TehPeGaSuS Dec 12, 2021
fc21955
Bump lxml from 4.6.3 to 4.6.5
dependabot[bot] Dec 13, 2021
ada7785
don't run filters/replaces on assured lines
jesopo Dec 19, 2021
904cb2d
git_webhooks/github.py: remove git url shortening
examknow Jan 20, 2022
046aa1b
github.py: remove git url shortening
examknow Jan 20, 2022
d58a77e
Merge pull request #339 from jesopo/launchd/rm-git-shortener
examknow Jan 20, 2022
9e4e492
git_webhooks/github.py: handle url shortening like everyone else
examknow Jan 20, 2022
bf76b41
github.py: use default shorteners
examknow Jan 20, 2022
1a697ba
Merge pull request #335 from PeGaSuS-Coder/patch-6
examknow Feb 13, 2022
5c6a27c
Merge pull request #314 from examknow/weather-kelvin
examknow Feb 13, 2022
891db2e
Merge pull request #336 from jesopo/dependabot/pip/lxml-4.6.5
examknow Feb 13, 2022
49bd338
Merge pull request #331 from JeDaYoshi/add-ipinfo
examknow Feb 13, 2022
81a3dec
Merge pull request #337 from jesopo/jess/cfilter-assure
examknow Feb 13, 2022
a4f41cd
ducks.py: do not accept `,bef` or `,trap` if ducks are disabled
examknow Feb 13, 2022
42fccba
git_webhooks/github.py: fix some rough edges
examknow Feb 14, 2022
6f6b40b
Merge pull request #342 from jesopo/launchd/ducks-ignore-commands
examknow Mar 1, 2022
8edf89d
git_webhooks/github.py: fix `ping()`
examknow Mar 1, 2022
9f33fb4
modules/youtube.py: add api exception handling
examknow Jul 11, 2022
6d0b1be
Merge branch 'develop' into master
examknow Jul 12, 2022
afb32e4
merge `master` with `develop`
examknow Jul 12, 2022
3f40ad9
Merge pull request #347 from bitbot-irc/launchd/yt-api-error
examknow Jul 12, 2022
1fd0e30
Merge pull request #341 from bitbot-irc/launchd/git-universal-shorting
examknow Sep 8, 2022
55cc01e
Switching from html5lib to lxml for tree builder issue in https://gis…
Oct 25, 2022
757a763
Removing deprecated loop=loop removed in 3.10 https://docs.python.org…
Oct 25, 2022
a06d540
Merge pull request #351 from Dark-Feather/darkfeather-rss-feedparsing
examknow Oct 26, 2022
398aca2
config.md: add information on `-c` option (#352)
deepend-tildeclub Jan 3, 2023
4e37f7c
shorturl.py: use bitly v4 api (#355)
examknow Jan 17, 2023
765689f
urbandictionary: use https (#357)
examknow Jan 18, 2023
a02bd2c
Update requirements.txt (#358)
TehPeGaSuS Mar 2, 2023
6e808e2
Delete nr.py (#360)
examknow Mar 20, 2023
c4a3043
requirement no longer necessary per #360
examknow Mar 20, 2023
25fde5b
Update nginx (#359)
Mar 20, 2023
a357866
ignore.py: allow ignoring commands in channel (#356)
examknow Mar 20, 2023
e68b773
wolfram|alpha: squash newlines put in returned input (#361)
xfnw Apr 19, 2023
0addf13
Bump tornado from 6.0.3 to 6.3.2 (#366)
dependabot[bot] May 30, 2023
ababe84
rss: Replace crashy double-formatting with standard format_token_repl…
progval Jun 14, 2023
59ed31f
rss: make format migration actually work
examknow Jun 17, 2023
af2ff08
rss: tweak migration regex
examknow Jun 17, 2023
03ce256
some fixes for python 3.11
examknow Jan 5, 2025
64a1153
http.py: updates for latest python (`html5lib` -> `html.parser`)
examknow Jan 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/bot.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,6 @@ bitly-api-key =

# https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line
github-token =

# https://ipinfo.io/account/token
ipinfo-token =
5 changes: 4 additions & 1 deletion docs/help/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

* Move `docs/bot.conf.example` to `~/.bitbot/bot.conf` and fill in the config options you care about. Ones blank or removed will disable relevant functionality.
* Run `./bitbotd -a` to add a server.
* Run `./bitbotd` to start the bot.
* Run `./bitbotd` to start the bot or `./bitbotd -c /path/to/bot.conf` for non-standard config location (outside of `~/.bitbot`).
* Run `./bitbotctl command master-password` to get the master admin password (needed to add regular admin accounts)
* Join `#bitbot` on a server with the bot (or invite it to another channel)
* `/msg <bot> register <password here>` to register your nickname with the bot
Expand All @@ -14,6 +14,9 @@

Generate a TLS keypair and point `bot.conf`'s `tls-key` to the private key and `tls-certificate` to the public key.

Below is an OpenSSL command example that will create a `bitbot-cert.pem` and `bitbot-key.pem` with `10y` validity (self-signed):
> openssl req -x509 -nodes -sha512 -newkey rsa:4096 -keyout bitbot-key.pem -out bitbot-cert.pem -days 3650 -subj "/CN=YourBotNick"

### Configure SASL

Configure the bot to use SASL to authenticate (usually used for `NickServ` identification)
Expand Down
2 changes: 1 addition & 1 deletion docs/help/rest_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Either set up a reverse proxy (with persisted Host header) with your favourite H
#### Apache2
* Run `$ a2enmod ssl proxy proxy_http` as root
* Copy example config file from [/docs/rest_api/apache2](/docs/rest_api/apache2) to `/etc/apache2/sites-enabled/`
* Edit `ServerName`, `SSLCertificateFile and `SSLCertificateKeyFile`
* Edit `ServerName`, `SSLCertificateFile` and `SSLCertificateKeyFile`
* `$ service apache2 restart` as root

#### Lighttpd
Expand Down
2 changes: 1 addition & 1 deletion docs/rest_api/apache2
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ Listen 5000

ProxyRequests off
ProxyPass / http://[::1]:5001/
ProxyPassReverse / http://[::1]:5001
ProxyPassReverse / http://[::1]:5001/
ProxyPreserveHost on
</VirtualHost>
2 changes: 1 addition & 1 deletion docs/rest_api/nginx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ server {

location / {
proxy_pass http://[::1]:5001;
proxy_set_header Host $host:$port;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
Expand Down
2 changes: 2 additions & 0 deletions docs/systemd/bitbot_user.service
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
# which can be disabled with: systemctl --user disable systemd-tmpfiles-clean.timer
#
# After placing this script in the correct location, and with bitbot stopped, type:
# systemcl --user daemon-reload
# Afert that start bitbot with:
# systemctl --user enable bitbot_user.service --now
# This will enable the systemd script and launch bitbot

Expand Down
9 changes: 9 additions & 0 deletions modules/ban_enforce.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

@utils.export("channelset", utils.BoolSetting("ban-enforce",
"Whether or not to parse new bans and kick who they affect"))
@utils.export("channelset", utils.IntSetting("ban-enforce-max",
"Do not enforce ban if the ban effects more than this many users. Default is half of total channel users."))
class Module(ModuleManager.BaseModule):
@utils.hook("received.mode.channel")
def on_mode(self, event):
Expand All @@ -14,14 +16,21 @@ def on_mode(self, event):
if mode[0] == "+" and mode[1] == "b":
bans.append(arg)

affected = 0
defaultmax = len(event["channel"].users) // 2
realmax = event["channel"].get_setting("ban-enforce-max", defaultmax)

if bans:
umasks = {u.hostmask(): u for u in event["channel"].users}
for ban in bans:
mask = utils.irc.hostmask_parse(ban)
matches = list(utils.irc.hostmask_match_many(
umasks.keys(), mask))
for match in matches:
affected = affected + 1
kicks.add(umasks[match])
if kicks:
if affected > realmax:
return
nicks = [u.nickname for u in kicks]
event["channel"].send_kicks(sorted(nicks), REASON)
4 changes: 2 additions & 2 deletions modules/channel_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def unmode(self, timer):
channel = server.channels.get(channel_name)

args = timer.kwargs.get("args", [timer.kwargs.get("arg", None)])
if args:
if any(args):
channel.send_modes(args, False)
else:
channel.send_mode(timer.kwargs["mode"], False)
Expand Down Expand Up @@ -238,7 +238,7 @@ def cmute(self, event):

if event["spec"][1]:
self.timers.add_persistent("unmode", event["spec"][1],
channel=event["spec"][0].id, mode="m")
channel=event["spec"][0].id, mode="-m")
@utils.hook("received.command.cunmute")
@utils.kwarg("require_mode", "o")
@utils.kwarg("require_access", "high,cmute")
Expand Down
14 changes: 11 additions & 3 deletions modules/dnsbl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,22 @@ def _check_lists(self, lists, address):
failed = []
for list in lists:
record = self._check_list(list.hostname, address)
if not record == None:
reason = list.process(record) or "unknown"
if record is not None:
a_record, txt_record = record
reason = list.process(a_record, txt_record) or "unknown"
failed.append((list.hostname, reason))
return failed

def _check_list(self, list, address):
list_address = "%s.%s" % (address, list)
try:
return dns.resolver.query(list_address, "A")[0].to_text()
a_record = dns.resolver.resolve(list_address, "A")[0].to_text()
except dns.resolver.NXDOMAIN:
return None

try:
txt_record = dns.resolver.resolve(list_address, "TXT")[0].to_text()
except:
txt_record = None

return (a_record, txt_record)
57 changes: 33 additions & 24 deletions modules/dnsbl/lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,62 @@ def __init__(self, hostname=None):
if not hostname == None:
self.hostname = hostname

def process(self, result: str):
return result
def process(self, a_record, txt_record):
out = a_record
if txt_record is not None:
out += f" - {txt_record}"
return out

class ZenSpamhaus(DNSBL):
hostname = "zen.spamhaus.org"
def process(self, result):
result = result.rsplit(".", 1)[1]
def process(self, a_record, txt_record):
result = a_record.rsplit(".", 1)[1]
if result in ["2", "3", "9"]:
return "spam"
desc = "spam"
elif result in ["4", "5", "6", "7"]:
return "exploits"
desc = "exploits"
else:
desc = "unknown"
return f"{result} - {desc}"

class EFNetRBL(DNSBL):
hostname = "rbl.efnetrbl.org"
def process(self, result):
result = result.rsplit(".", 1)[1]
def process(self, a_record, txt_record):
result = a_record.rsplit(".", 1)[1]
if result == "1":
return "proxy"
desc = "proxy"
elif result in ["2", "3"]:
return "spamtap"
desc = "spamtap"
elif result == "4":
return "tor"
desc = "tor"
elif result == "5":
return "flooding"
desc = "flooding"
return f"{result} - {desc}"

class DroneBL(DNSBL):
hostname = "dnsbl.dronebl.org"
def process(self, result):
result = result.rsplit(".", 1)[1]
if result in ["8", "9", "10", "11", "14"]:
return "proxy"
elif result in ["3", "6", "7"]:
return "flooding"
elif result in ["12", "13", "15", "16"]:
return "exploits"

class AbuseAtCBL(DNSBL):
hostname = "cbl.abuseat.org"
def process(self, result):
result = result.rsplit(".", 1)[1]
def process(self, a_record, txt_record):
result = a_record.rsplit(".", 1)[1]
if result == "2":
return "abuse"
desc = "abuse"
else:
desc = "unknown"
return f"{result} - {desc}"

class TorExitDan(DNSBL):
hostname = "torexit.dan.me.uk"
def process(self, a_record, txt_record):
return "tor exit"

DEFAULT_LISTS = [
ZenSpamhaus(),
EFNetRBL(),
DroneBL(),
AbuseAtCBL()
AbuseAtCBL(),
TorExitDan()
]

def default_lists():
Expand Down
8 changes: 8 additions & 0 deletions modules/ducks.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ def _no_duck(self, channel, user, stderr):
@utils.kwarg("help", "Befriend a duck")
@utils.spec("!-channelonly")
def befriend(self, event):
if not event["target"].get_setting("ducks-enabled", False):
return event["stderr"].write(
"Ducks are not enabled in this channel"
)
if event["target"].duck_active:
action = self._duck_action(event["target"], event["user"],
"befriended", "ducks-befriended")
Expand All @@ -109,6 +113,10 @@ def befriend(self, event):
@utils.kwarg("help", "Trap a duck")
@utils.spec("!-channelonly")
def trap(self, event):
if not event["target"].get_setting("ducks-enabled", False):
return event["stderr"].write(
"Ducks are not enabled in this channel"
)
if event["target"].duck_active:
action = self._duck_action(event["target"], event["user"],
"trapped", "ducks-shot")
Expand Down
13 changes: 8 additions & 5 deletions modules/git_webhooks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Module(ModuleManager.BaseModule):
_name = "Webhooks"

def on_load(self):
self._github = github.GitHub(self.log)
self._github = github.GitHub(self.log, self.exports)
self._gitea = gitea.Gitea()
self._gitlab = gitlab.GitLab()

Expand Down Expand Up @@ -135,17 +135,17 @@ def _webhook(self, webhook_type, webhook_name, handler, payload_str,
for output, url in outputs:
output = "(%s) %s" % (
utils.irc.color(source, colors.COLOR_REPO), output)

if channel.get_setting("git-prevent-highlight", False):
output = self._prevent_highlight(server, channel,
output)

if url:
if channel.get_setting("git-shorten-urls", False):
url = self.exports.get("shorturl")(server, url,
context=channel) or url
output = "%s - %s" % (output, url)

if channel.get_setting("git-prevent-highlight", False):
output = self._prevent_highlight(server, channel,
output)

hide_prefix = channel.get_setting("git-hide-prefix", False)
self.events.on("send.stdout").call(target=channel,
module_name=webhook_name, server=server, message=output,
Expand Down Expand Up @@ -228,6 +228,9 @@ def github_webhook(self, event):
if existing_hook:
raise utils.EventError("There's already a hook for %s" %
hook_name)
if hook_name == None:
command = "%s%s" % (event["command_prefix"], event["command"])
raise utils.EventError("Not enough arguments (Usage: %s add <hook>)" % command)

all_hooks[hook_name] = {
"events": DEFAULT_EVENT_CATEGORIES.copy(),
Expand Down
Loading