ayust / kitnirc

Python IRC bot framework.
MIT License
11 stars 7 forks source link

Bot believes it's not in channel when trying to set a mode. #13

Closed flexd closed 10 years ago

flexd commented 10 years ago

I am trying to op someone based on a command, but kitnirc seems determined that I am not in the channel.

  _log.info("Channel: %r", recipient)
  _log.info("Server.channels: %r", client.server.channels)
  client.mode(recipient, add={'o': [actor]})
  client.reply(recipient, actor, "Okay.")

Log output

INFO 2014-07-14 13:44:12,824 modules.helloworld:0034 - Channel: kitnirc.client.Channel('#yamc')
INFO 2014-07-14 13:44:12,824 modules.helloworld:0035 - Server.channels: {'#yamc': kitnirc.client.Channel('#yamc')}
WARNING 2014-07-14 13:44:12,825 kitnirc.client:0442 - Ignoring request to set modes in channel '#yamc' because we are not in that channel.

Relevant code: https://github.com/ayust/kitnirc/blob/master/kitnirc/client.py#L429

ayust commented 10 years ago

Looks like the problem is the in check - .channels is keyed off channel name, but you're passing in a Channel object, and it's never converted to a string. That can probably be fixed by calling str() before doing the in check; let me check if that will break anything - otherwise I'll patch it right now.

flexd commented 10 years ago

I fixed https://github.com/ayust/kitnirc/blob/master/kitnirc/client.py#L440, by changing it to if channel.name not in self.server.channels

flexd commented 10 years ago

However, I still can't set a user mode (+o) because it does not seem to recognise o as a proper mode WARNING 2014-07-14 14:15:09,256 kitnirc.client:0471 - Ignoring request to set channel mode 'o' because it is not a recognized mode.

ayust commented 10 years ago

Fix for original issue is checked in as d2fdc7c1d59b17be2da7f0b3a845edb782bce224. Looking at the other issue now.

flexd commented 10 years ago

argument_modes is set(['b', 'e', 'f', 'I', 'k', 'j', 'L', 'l']) on client.py#L461

ayust commented 10 years ago

Can you tell me what the values of the variables set on client.py#446 are?

flexd commented 10 years ago
WARNING 2014-07-14 14:27:19,845 kitnirc.client:0449 - Argument Modes set(['b', 'e', 'f', 'I', 'k', 'L'])
WARNING 2014-07-14 14:27:19,845 kitnirc.client:0450 - user Modes set(['A', 'C', 'B', 'G', 'H', 'O', 'N', 'S', 'R', 'T', 'W', 'V', 'a', 'd', 'g', 'i', 'h', 'o', 'q', 'p', 's', 'r', 't', 'w', 'v', 'x', 'z'])
WARNING 2014-07-14 14:27:19,846 kitnirc.client:0451 - List modes set(['I', 'b', 'e'])
WARNING 2014-07-14 14:27:19,846 kitnirc.client:0452 - always_arg_modes set(['k', 'L', 'f'])
WARNING 2014-07-14 14:27:19,846 kitnirc.client:0453 - set_arg_modes set(['j', 'l'])
WARNING 2014-07-14 14:27:19,846 kitnirc.client:0454 - toggle_modes set(['A', 'C', 'G', 'K', 'M', 'O', 'N', 'Q', 'S', 'R', 'T', 'V', 'Z', 'c', 'i', 'j', 'm', 'l', 'n', 'p', 's', 'r', 'u', 't', 'z'])
ayust commented 10 years ago

What network is this on? Looks like it's not including user-channel-privilege modes in the set of always-arg modes, which is unfortunate. :<

flexd commented 10 years ago

irc.coldfront.net

flexd commented 10 years ago

Your host is snow.coldfront.net, running version Unreal3.2.9 CMDS=KNOCK,MAP,DCCALLOW,USERIP UHNAMES NAMESX SAFELIST HCN MAXCHANNELS=40 CHANLIMIT=#:40 MAXLIST=b:60,e:60,I:60 NICKLEN=30 CHANNELLEN=32 TOPICLEN=307 KICKLEN=307 AWAYLEN=307 :are supported by this server MAXTARGETS=20 WALLCHOPS WATCH=128 WATCHOPTS=A SILENCE=15 MODES=12 CHANTYPES=# PREFIX=(qaohv)~&@%+ CHANMODES=beI,kfL,lj,psmntirRcOAQKVCuzNSMTGZ NETWORK=Coldfront CASEMAPPING=ascii EXTBAN=~,qjncrR ELIST=MNUCT :are supported by this server STATUSMSG=~&@%+ EXCEPTS INVEX :are supported by this server

ayust commented 10 years ago

Okay, I think I see the issue. mode() needs to incorporate _get_prefixes output into its list of modes that can be set in a channel. I'll patch that quick.

ayust commented 10 years ago

I think 29edb9a818cbd72ecedb706ca17694521c1b26b8 should fix the second issue. Can you see if that solves your problem?

flexd commented 10 years ago

A somewhat related issue:

WARNING 2014-07-17 13:33:53,342 kitnirc.client:0479 - Ignoring request to set channel mode 'ov' because it is not a recognized mode.

Trying to set two modes at the same time should be possible?

ayust commented 10 years ago

Add them as separate dictionary entries, not the same one.

On Thu Jul 17 2014 at 4:34:56 AM, Kristoffer Berdal < notifications@github.com> wrote:

A somewhat related issue:

WARNING 2014-07-17 13:33:53,342 kitnirc.client:0479 - Ignoring request to set channel mode 'ov' because it is not a recognized mode.

Trying to set two modes at the same time should be possible?

— Reply to this email directly or view it on GitHub https://github.com/ayust/kitnirc/issues/13#issuecomment-49295599.