discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Editing TalkSoup's /mode command


From: Svetlana Tkachenko
Subject: Editing TalkSoup's /mode command
Date: Fri, 29 Jul 2016 21:45:32 +1000
User-agent: GNUMail (Version 1.2.2)

Good day,

I am using GNUstep with wmaker on Debian.

With TalkSoup 1.1, I would like to edit the '/mode' command to not
require a channel name if I am executing it in a channel tab. If I am
in #gnustep and I type '/mode +t', it should work; I should not be
obligated to type '/mode #gnustep +t'. But as of present, I am
required to supply the channel name with each /mode command.

I am lazy, and I found that '/topic hi' in a channel tab works without
me having to type the channel name, so I started trying to steal code
from the '/topic' command for /mode.

I thought that both commands use commandMode and commandTopic from
./Sources/commands.m. I read commandTopic:

- (NSAttributedString *)commandTopic: (NSString *)command connection: connection
{
id array;
id who;
id arg = nil;

if (!connection) return NO_CONNECT;

array = [command separateIntoNumberOfArguments: 2];

if ([array count] < 1)
{
return S2AS(_(@"Usage: /topic <channel> [topic]"));
}

who = [array objectAtIndex: 0];


if ([array count] > 1)
{
arg = [array objectAtIndex: 1];
}

[_TS_ setTopicForChannel: S2AS(who) to: S2AS(arg)
 onConnection: connection withNickname: S2AS([connection nick])
 sender: output];

return nil;
}



I start thinking that the 'who' is the channel in which I am setting the topic.
I break this function by adding this line for it to print out the
'who' and do nothing afterwards:

    who = [array objectAtIndex: 0];
+  return S2AS(_(who));


Then I /also/ break commandMode in the same manner:


- (NSAttributedString *)commandMode: (NSString *)command connection: connection
{
id array;
id mode;
id arg = AUTORELEASE([NSMutableArray new]);
id obj;
int ind, max;

if (!connection) return NO_CONNECT;

+ array = [command separateIntoNumberOfArguments: 2];
+
+ who = [array objectAtIndex: 0];
+      return S2AS(_(who));
+
- array = [command separateIntoNumberOfArguments: -1];
-
- max = [array count];
-
- if (max <= 1)
- {
- return S2AS(_(@"Usage: /mode <object> <mode(s)> [arguments]"));
- }
-
- mode = [array objectAtIndex: 1];
- obj = [array objectAtIndex: 0];
-
- for (ind = 2; ind < max; ind++)
- {
- [arg addObject: S2AS([array objectAtIndex: ind])];
- }
-
- [_TS_ setMode: S2AS(mode) on: S2AS(obj) withParams: arg
-  onConnection: connection withNickname: S2AS([connection nick])
-  sender: output];
-
- return nil;
}

After compiling this, the behaviour is:

1. '/mode #foo +t' prints '#foo' in the chat
2, '/mode +t' prints '+t' in the chat
3. '/topic bar' prints nothing and just changes the topic

I guess the '/topic' command doesn't really use that commandTopic subroutine.

1. Why is commandTopic present in the file, if it seems to never be called?
2. What happens when I type '/topic bar' in the #foo channel tab?
Precisely how does it pick up the current channel name?

Regards,
Svetlana.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]