Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
challenges
ircbot
Commits
2fe28465
Commit
2fe28465
authored
May 10, 2022
by
awe
Browse files
Fixed unintended bugs and some broken regexes
Thanks Alkanor & Impuls for reporting the bugs :)
parent
3d6b3051
Changes
6
Hide whitespace changes
Inline
Side-by-side
Dockerfile
View file @
2fe28465
# docker build . -t ircbot:latest
# docker run -itd --restart=always -v $PWD:/home/ircbot --name ircbot ircbot:latest
From
alpine
From
alpine
:3.10
LABEL
maintainer "awe"
RUN
apk update
&&
apk upgrade
RUN
apk add python3 python3-dev gcc musl-dev libffi-dev openssl-dev capstone py3-capstone py3-lxml py
2
-httplib2 py-requests
RUN
apk add python3 python3-dev gcc musl-dev libffi-dev openssl-dev capstone py3-capstone py3-lxml py
3-pip py3
-httplib2 py-requests
RUN
adduser
-s
/usr/sbin/nologin
-k
/dev/null
-D
-H
-h
/home/ircbot ircbot
RUN
pip3
install
TwitterAPI
...
...
irc/ircbot.py
View file @
2fe28465
...
...
@@ -123,15 +123,16 @@ class IrcBot:
continue
# Received a ctcp command
pattern
=
"^:(.+)!.+ PRIVMSG "
+
self
.
name
+
" :"
+
chr
(
0x01
)
pattern
+=
"(.+)"
+
chr
(
0x01
)
pattern
=
"^:(.+)!.+ PRIVMSG "
+
self
.
name
+
" :"
+
chr
(
0x01
)
+
"(.+)"
+
chr
(
0x01
)
m
=
re
.
search
(
pattern
,
data
)
if
m
is
not
None
:
self
.
ctcp
(
m
.
group
(
2
),
m
.
group
(
1
))
continue
# Received a private message
if
data
.
find
(
"PRIVMSG"
)
!=
-
1
:
m
=
re
.
search
(
"^:(.+)![^ ]+ PRIVMSG ([^ ]+)(?:\s+):(.*)$"
,
data
)
if
m
is
not
None
:
t
=
Parsemsg
(
self
.
server
,
self
.
name
,
data
)
t
.
start
()
if
t
.
join_thread
():
...
...
irc/ircserver.py
View file @
2fe28465
...
...
@@ -25,6 +25,7 @@ from irc.ircaction import recordIrcAction
from
datetime
import
datetime
import
time
import
socket
import
string
import
ssl
import
console.term
as
term
import
sys
...
...
@@ -178,6 +179,14 @@ class IrcServer:
if
self
.
bypassLog
(
content
):
return
charset
=
string
.
ascii_letters
+
string
.
digits
+
'#-_.'
if
any
(
c
not
in
charset
for
c
in
self
.
server
):
return
if
any
(
c
not
in
charset
for
c
in
file
):
return
try
:
f
=
None
...
...
plugins/crypto/rot.py
View file @
2fe28465
...
...
@@ -18,6 +18,7 @@
# You should have received a copy of the GNU General Public License
# along with W3-BoT. If not, see <http://www.gnu.org/licenses/>.
import
string
from
plugins.command
import
Command
,
USAGE
...
...
@@ -57,17 +58,19 @@ class Rot(Command):
If nomod is set to 1, then usual modulo 26 is not performed.
"""
charset
=
string
.
ascii_letters
+
string
.
digits
+
string
.
punctuation
+
' '
res
=
""
for
c
in
text
:
ch
=
c
if
nomod
:
res
+=
chr
((
ord
(
c
)
+
n
)
%
127
)
else
:
if
c
>=
'a'
and
c
<=
'z'
:
res
+=
chr
(
ord
(
'a'
)
+
(
ord
(
c
)
-
ord
(
'a'
)
+
n
)
%
26
)
elif
c
>=
'A'
and
c
<=
'Z'
:
res
+=
chr
(
ord
(
'A'
)
+
(
ord
(
c
)
-
ord
(
'A'
)
+
n
)
%
26
)
else
:
res
+=
c
ch
=
chr
((
ord
(
c
)
+
n
)
%
127
)
elif
c
>=
'a'
and
c
<=
'z'
:
ch
=
chr
(
ord
(
'a'
)
+
(
ord
(
c
)
-
ord
(
'a'
)
+
n
)
%
26
)
elif
c
>=
'A'
and
c
<=
'Z'
:
ch
=
chr
(
ord
(
'A'
)
+
(
ord
(
c
)
-
ord
(
'A'
)
+
n
)
%
26
)
res
+=
ch
if
ch
in
charset
else
repr
(
ch
)[
1
:
-
1
]
return
res
@
classmethod
...
...
plugins/misc/chuck.py
View file @
2fe28465
...
...
@@ -37,7 +37,7 @@ class Chuck(Command):
txt
=
response
.
read
().
decode
()
regex
=
'<div class="
factbody">(?:\s+)([^<]+)<div class="vote"
>'
regex
=
'<div class="
card-body bg-light rounded">(?:\s+)<p class="card-text">([^<]+)</p>(?:\s+)</div
>'
m
=
re
.
search
(
regex
,
txt
)
if
not
m
:
...
...
plugins/misc/vdm.py
View file @
2fe28465
...
...
@@ -40,7 +40,7 @@ class Vdm(Command):
txt
=
response
.
content
.
decode
()
regex
=
'<
div class="article-contents">\s*<a class="article-link" href="
[^"]+">\s*([^
\n
]+)\s*</a>'
regex
=
'<
a href="[^"]+" class="block text-
[^"]+">\s*([^
\n
]+)\s*</a>'
m
=
re
.
search
(
regex
,
txt
)
if
m
:
res
=
self
.
remove_html_tags
(
"Aujourd'hui, %s"
%
m
.
group
(
1
))
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment