Anope IRC Services

Please login or register.

Login with username, password and session length
Advanced search  

News:

Pages: [1]   Go Down

Author Topic: PTlink + Anope + Guestnick  (Read 14112 times)

0 Members and 1 Guest are viewing this topic.

stdin

  • Anope User
  • Offline Offline
  • Posts: 19
PTlink + Anope + Guestnick
« on: March 23, 2008, 08:38:17 AM »

Can someone show me how to make a while scans all channels of a user, puts the channel in a string, and makes him leave of channel? (Resume: Part all channels after changing nick to guest).

I need to know how to make the while, what  to set in u's(User * nick), what to set in *c (Channel) and *uc (another thing which i dont remember) :( please help guys!




Sorry for the double post!

[Edited on 23-3-2008 by stdin]

[Edited on 24-3-2008 by katsklaw]
Logged

Jan Milants

  • Team
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 1372
(No subject)
« Reply #1 on: March 23, 2008, 10:48:37 AM »

Anope Doxy
should contain everything you need to know.. under users you ll find user_::u_chanlist
Logged
If you like me donate coins to 1FBmZVT4J8WAUMHKqpWhgNVj3XXnRN1cCk :)

stdin

  • Anope User
  • Offline Offline
  • Posts: 19
:(
« Reply #2 on: March 24, 2008, 03:23:38 AM »

well it does explain how's the struct, but i dont know how to make the while :( can you please help me ?
Logged

katsklaw

  • Guest
(No subject)
« Reply #3 on: March 24, 2008, 11:01:58 AM »

Nothing is better than a working example ... peek at the source code of any module that may do something similar.
Logged

stdin

  • Anope User
  • Offline Offline
  • Posts: 19
(No subject)
« Reply #4 on: March 24, 2008, 11:04:02 AM »

Believe me, i already tried, otherwise i wont be asking for help, i tried everything, i also made some personal modules, but i just can't list all channels in a while and put em in a string for use svspart.. \=
Logged

Jan Milants

  • Team
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 1372
(No subject)
« Reply #5 on: March 24, 2008, 11:08:29 AM »

Code: [Select]

User *u; (supposing this one exists already..)
struct u_chanlist *uc;
for (uc = u->chans; u; u = u->next) {
    Channel *c = uc->chan;
    // your code here..
}


and that kinda loop is used several times in the core... methinks you didn't look too deep..

[Edited on 24-3-2008 by Viper]
Logged
If you like me donate coins to 1FBmZVT4J8WAUMHKqpWhgNVj3XXnRN1cCk :)

stdin

  • Anope User
  • Offline Offline
  • Posts: 19
(No subject)
« Reply #6 on: March 24, 2008, 11:21:49 AM »

Thank you very much :P i had the Channel *c defined before and not in the loop for.

Quote

int guest_part(int argc, char **argv)
{
   User *u;
   struct u_chanlist *uc;
   for (uc = u->chans; uc; uc = uc->next) {
      Channel *c = uc->chan;
      anope_cmd_svspart(s_OperServ, u->nick, uc->chan);
   }

}
   if (argc >= 1) {
      if (strstr(argv[0], NSGuestNickPrefix)) {
            send_cmd(s_NickServ, "SVSJOIN %s #GuestRoom", argv[0]);
        }
     }
   return MOD_CONT;
}


may work? *-)

[Edited on 24-3-2008 by stdin]

[Edited on 24-3-2008 by stdin]
Logged

Jan Milants

  • Team
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 1372
(No subject)
« Reply #7 on: March 24, 2008, 11:41:44 AM »

it doesn't matter where you define channel... as long as it s reachable.
and no that won't work because you never assign anything to the user *u ... so if the user doesn't exist, you can expect to get the channellist...
Logged
If you like me donate coins to 1FBmZVT4J8WAUMHKqpWhgNVj3XXnRN1cCk :)

stdin

  • Anope User
  • Offline Offline
  • Posts: 19
(No subject)
« Reply #8 on: March 24, 2008, 11:45:43 AM »

The sender is parv[0], anyways if i replace

Quote

int guest_part(int argc, char **argv)


to ..

Quote

int guest_part(int argc, char **argv, User *u)


It may work?
Logged

Jan Milants

  • Team
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 1372
(No subject)
« Reply #9 on: March 24, 2008, 12:24:56 PM »

that depends.. if you change the methods params, you also need to edit the call to the method, but i doubt you can
i m guessing it s a method called by anope in which case you cannot. you have to assign the used based on the argv anope passes to you..
i d highly recommend looking at some other modules because i get the feeling you are just guessing around a bit...
Logged
If you like me donate coins to 1FBmZVT4J8WAUMHKqpWhgNVj3XXnRN1cCk :)

stdin

  • Anope User
  • Offline Offline
  • Posts: 19
(No subject)
« Reply #10 on: March 24, 2008, 12:28:33 PM »

its a module, ircd_guestnick.c if i'm not in error, by n00bie, but he used the old bug solution "join 0", but in PTlink, that doesn't happen ;)

yes, maybe i'm guessing a little, but its boring when you program in stuff which you know what you doing, what makes it fun and entertains you is when you try program something which you dont know how, and you try find out as I am doing ;p

Well, i couldn't make the while using parv[0] !?

[Edited on 24-3-2008 by stdin]
Logged

Jan Milants

  • Team
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 1372
(No subject)
« Reply #11 on: March 24, 2008, 12:31:38 PM »

no, take the users' nickname out of argv[] and use u=finduser().. but i don't know by heart at which index the users' nick is in argv...
Logged
If you like me donate coins to 1FBmZVT4J8WAUMHKqpWhgNVj3XXnRN1cCk :)

stdin

  • Anope User
  • Offline Offline
  • Posts: 19
(No subject)
« Reply #12 on: March 24, 2008, 12:34:22 PM »

Yes i was replying suggesting finduser too atm...

what do you mean? parv[0] = sender prefix !?
Logged

stdin

  • Anope User
  • Offline Offline
  • Posts: 19
(No subject)
« Reply #13 on: March 24, 2008, 12:36:46 PM »

I'm pretty sure this may work:

Quote

   User *u;
   Channel *c;
   char *partchan;
   u = finduser(argv[0]);
   struct u_chanlist *uc;
   for (uc = u->chans; uc; uc = uc->next) {
      partchan = uc->chan;
      anope_cmd_svspart(s_OperServ, u->nick, partchan);
   }


The actual channel isn't uc->chan ? why the hell i get a warn for incompatible types when i try put the chan uc->chan in the pointer partchan !?
It doesn't work... on my client it appears

—› no such channel: #
 :(


[Edited on 24-3-2008 by stdin]
Logged

Jan Milants

  • Team
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 1372
(No subject)
« Reply #14 on: March 24, 2008, 01:38:07 PM »

of course you can't assign uc->chan to the pointer partchan... uc->chan is a pointer to a Channel whereas partchan is a pointer to a string..
Logged
If you like me donate coins to 1FBmZVT4J8WAUMHKqpWhgNVj3XXnRN1cCk :)

stdin

  • Anope User
  • Offline Offline
  • Posts: 19
(No subject)
« Reply #15 on: March 24, 2008, 01:41:22 PM »

So how do i get the channel there?

            send_cmd(s_NickServ, "SVSPART %s %s", argv[0], uc->chan);

wont work too :x


[Edited on 24-3-2008 by stdin]
Logged

Jan Milants

  • Team
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 1372
(No subject)
« Reply #16 on: March 24, 2008, 01:48:06 PM »

Code: [Select]
anope_cmd_svspart(s_OperServ, argv[0], uc->chan->name);
will
Logged
If you like me donate coins to 1FBmZVT4J8WAUMHKqpWhgNVj3XXnRN1cCk :)

stdin

  • Anope User
  • Offline Offline
  • Posts: 19
(No subject)
« Reply #17 on: March 24, 2008, 01:52:53 PM »

THANK YOU VERY MUCH.
Logged

katsklaw

  • Guest
(No subject)
« Reply #18 on: March 24, 2008, 09:11:41 PM »

If PTLink supports the old /join 0 trick like a lot of IRCds still do then instead of looping through the channels, just issue a single command which will handle the parting and the joining all in the same command:

send_cmd(s_NickServ, "SVSJOIN %s 0,#GuestRoom", u->nick);

The above string will make your code smaller as well as less resource intensive on Anope.

Additionally, there is all kinds of these loop examples throughout the entire code base. So yes, there are working examples.
Logged

Jan Milants

  • Team
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 1372
(No subject)
« Reply #19 on: March 24, 2008, 09:52:54 PM »

"join 0" doesn't work in ptlink..
and i m personally not a big fan of using "tricks" like that anyways...

but yeah.. there are for most thingsperfect examples either in the core or in good 3rd party modules.. only have to spend some time doing research :)

[Edited on 24-3-2008 by Viper]
Logged
If you like me donate coins to 1FBmZVT4J8WAUMHKqpWhgNVj3XXnRN1cCk :)

katsklaw

  • Guest
(No subject)
« Reply #20 on: March 25, 2008, 12:59:53 PM »

when it comes down to cpu cycles and the number of times a certain bit of code is run on how many users, then it's logical to use whatever means available to reduce the resource usage as much as possible. So just because one doesn't like to do something doesn't negate the fact that it just might be the best way to do something. Case in point, there is several ways things are done in the Anope code that one developer or another doesn't like, but it was done or stayed anyway because it's the most logical or "best" way to do it. Besides, not trying to be rude, but it's about what stdin likes and not what you like. I personally don't like the concept of the module being written, but as I said, it's not about what I like .. it's about stdin. :)

Additionally, I used the term "trick" in a nostalgic sense as a lot admins, even though they may have been around for several years, don't know about the /join 0 command that was left over from IRC v1 but ported to IRCv2 even though the 0 parameter contradicts RFC1459 where it says the channel must start with # or & but that's another topic. :)

[Edited on 25-3-2008 by katsklaw]
Logged

Jobe

  • Contributor
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 1023
    • Anope IRC Services
(No subject)
« Reply #21 on: March 26, 2008, 01:12:03 PM »

Quote
Originally posted by katsklaw
Additionally, I used the term "trick" in a nostalgic sense as a lot admins, even though they may have been around for several years, don't know about the /join 0 command that was left over from IRC v1 but ported to IRCv2 even though the 0 parameter contradicts RFC1459 where it says the channel must start with # or & but that's another topic. :)
[Edited on 25-3-2008 by katsklaw]

And on a technicality, since you don't join "0" it's not breaking the RFC anyway. As you say, channel names must start with "#" or "&" That would mean you can only be IN channels beginning with "#" and "&" so since JOIN 0 doesn't actually join you to a channel called "0" it's not in violation.
Logged
Your IP: ()
My IRC Status:

Come along and visit http://www.anopequotes.org/
Pages: [1]   Go Up