Implemented @Griatch's suggestions

This commit is contained in:
Sina Mashek 2016-03-26 15:28:15 -07:00
parent 2d54bc33ab
commit 4c113f9ab7
2 changed files with 10 additions and 13 deletions

View file

@ -755,7 +755,8 @@ class CmdIRC2Chan(MuxCommand):
link an evennia channel to an external IRC channel
Usage:
@irc2chan[/switches] <evennia_channel> = <ircnetwork> <[+]port> <#irchannel> <botname>
@irc2chan[/switches] <evennia_channel> = <ircnetwork> <port> <#irchannel> <botname>
@irc2chan/ssl "
@irc2chan/list
@irc2chan/delete botname|#dbid
@ -774,8 +775,7 @@ class CmdIRC2Chan(MuxCommand):
vice versa. The bot will automatically connect at server start, so this
comman need only be given once. The /disconnect switch will permanently
delete the bot. To only temporarily deactivate it, use the {w@services{n
command instead. To connect with SSL, add a plus sign (+) before the port
number.
command instead.
"""
key = "@irc2chan"
@ -821,7 +821,7 @@ class CmdIRC2Chan(MuxCommand):
return
if not self.args or not self.rhs:
string = "Usage: @irc2chan[/switches] <evennia_channel> = <ircnetwork> <[+]port> <#irchannel> <botname>"
string = "Usage: @irc2chan[/switches] <evennia_channel> = <ircnetwork> <port> <#irchannel> <botname>"
self.msg(string)
return
@ -831,15 +831,13 @@ class CmdIRC2Chan(MuxCommand):
irc_network, irc_port, irc_channel, irc_botname = \
[part.strip() for part in self.rhs.split(None, 3)]
irc_channel = "#%s" % irc_channel
if "+" in irc_port:
irc_ssl = True
irc_port = irc_port[1:]
except Exception:
string = "IRC bot definition '%s' is not valid." % self.rhs
self.msg(string)
return
botname = "ircbot-%s" % irc_botname
irc_ssl = "ssl" in self.switches
# create a new bot
bot = PlayerDB.objects.filter(username__iexact=botname)

View file

@ -312,12 +312,11 @@ class IRCBotFactory(protocol.ReconnectingClientFactory):
"""
if self.port:
if ssl:
"""
Requires PyOpenSSL
"""
service = reactor.connectSSL(self.network, int(self.port), self, ssl.ClientContextFactory())
try:
import OpenSSL
service = reactor.connectSSL(self.network, int(self.port), self, ssl.ClientContextFactory())
except ImportError:
self.caller.msg("To use SSL, the PyOpenSSL module must be installed.")
else:
service = internet.TCPClient(self.network, int(self.port), self)
self.sessionhandler.portal.services.addService(service)