Mostly code style changes

This commit is contained in:
luk3yx 2019-06-20 18:21:25 +12:00
parent 12347cb1a6
commit adda651e0f
2 changed files with 15 additions and 13 deletions

View File

@ -6,8 +6,8 @@
# © 2018 by luk3yx
#
import sys
from miniirc import IRC
import miniirc, sys
assert miniirc.ver >= (1,4,0), 'This bot requires miniirc >= v1.4.0.'
# Variables
nick = 'miniirc-test' + str(hash('.'))[1:4] # Make a unique(-ish) nickname
@ -29,17 +29,17 @@ irc = IRC(ip, port, nick, channels, ident = ident, realname = realname,
# Handle normal messages
# This could probably be better than a large if/else statement.
@irc.Handler('PRIVMSG')
@irc.Handler('PRIVMSG', colon=False)
def handle_privmsg(irc, hostmask, args):
channel = args[0]
text = args[-1][1:].split(' ')
text = args[-1].split(' ')
cmd = text[0].lower()
# Unprefixed commands here
if cmd.startswith("meep"):
irc.msg(channel, "Meep™!")
if cmd.startswith('meep'):
irc.msg(channel, '\u200bMeep!')
elif cmd.startswith(prefix):
# Prefixed commands
cmd = cmd[1:]
cmd = cmd[len(prefix):]
if cmd == 'yay':
irc.msg(channel, '\u200bYay!')
elif cmd == 'rev':
@ -54,4 +54,5 @@ def handle_privmsg(irc, hostmask, args):
'I am {}, an example miniirc bot.'.format(irc.nick))
# Connect
if __name__ == '__main__':
irc.connect()

View File

@ -43,4 +43,5 @@ def handle_stdin(irc, hostmask, args):
irc.msg(channels[0], line)
time.sleep(interval)
if __name__ == '__main__':
irc.connect()