Created
August 26, 2017 10:33
-
-
Save ysc3839/76418598bb6dd907c227bc7487fe269d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import _vcmp | |
from _vcmp import functions | |
import irc.bot | |
class TestBot(irc.bot.SingleServerIRCBot): | |
def __init__(self, channel, nickname, server, port=6667): | |
irc.bot.SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) | |
self.channel = channel | |
def on_nicknameinuse(self, c, e): | |
c.nick(c.get_nickname() + "_") | |
def on_welcome(self, c, e): | |
print(e.arguments[0]) | |
c.join(self.channel) | |
def on_privmsg(self, c, e): | |
print(e.arguments[0]) | |
def on_pubmsg(self, c, e): | |
print(e.arguments[0]) | |
bot = TestBot('#RTV', 'Testbot', 'irc.liberty-unleashed.co.uk') | |
def callback(func): | |
setattr(_vcmp.callbacks, func.__name__, func) | |
return func | |
@callback | |
def on_server_initialise(): | |
print('Python init!') | |
bot._connect() | |
return True | |
@callback | |
def on_server_frame(elapsedTime): | |
bot.reactor.process_once() | |
@callback | |
def on_server_shutdown(): | |
bot.connection.privmsg('#RTV', "Server shutdown!") | |
print("Server shutdown!") | |
@callback | |
def on_player_connect(playerId): | |
bot.connection.privmsg('#RTV', "on_player_connect {}".format(functions.get_player_name(playerId))) | |
print("on_player_connect {}".format(functions.get_player_name(playerId))) | |
@callback | |
def on_player_disconnect(playerId, reason): | |
bot.connection.privmsg('#RTV', "on_player_disconnect {} reason:{}".format(functions.get_player_name(playerId), reason)) | |
print("on_player_disconnect {} reason:{}".format(functions.get_player_name(playerId), reason)) | |
@callback | |
def on_player_message(playerId, message): | |
bot.connection.privmsg('#RTV', "on_player_message {}:{}".format(functions.get_player_name(playerId), message)) | |
print("on_player_message {}:{}".format(functions.get_player_name(playerId), message)) | |
@callback | |
def on_player_command(playerId, message): | |
bot.connection.privmsg('#RTV', "on_player_command {}:{}".format(functions.get_player_name(playerId), message)) | |
print("on_player_command {}:{}".format(functions.get_player_name(playerId), message)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good.