static void cmd_chinfo(int idx, char *par) { if (!use_info) { dprintf(idx, "Info storage is turned off.\n"); return; } char *handle = newsplit(&par); if (!handle[0]) { dprintf(idx, "Usage: chinfo <handle> [channel] <new-info>\n"); return; } struct userrec *u1 = get_user_by_handle(userlist, handle); if (!u1 || (u1 && !whois_access(dcc[idx].user, u1))) { dprintf(idx, "No such user.\n"); return; } char *chname = NULL; if (par[0] && strchr(CHANMETA, par[0])) { chname = newsplit(&par); if (!findchan_by_dname(chname)) { dprintf(idx, "No such channel.\n"); return; } } else chname = 0; if (u1->bot && !(dcc[idx].user->flags & USER_MASTER)) { dprintf(idx, "You have to be master to change bots info.\n"); return; } if ((u1->flags & USER_OWNER) && !(dcc[idx].user->flags & USER_OWNER)) { dprintf(idx, "You can't change info for the bot owner.\n"); return; } if (chname) { get_user_flagrec(dcc[idx].user, &user, chname); get_user_flagrec(u1, &victim, chname); if ((chan_owner(victim) || glob_owner(victim)) && !(glob_owner(user) || chan_owner(user))) { dprintf(idx, "You can't change info for the channel owner.\n"); return; } } putlog(LOG_CMDS, "*", "#%s# chinfo %s %s %s", dcc[idx].nick, handle, chname ? chname : par, chname ? par : ""); if (!strcasecmp(par, "none")) par[0] = 0; if (chname) { set_handle_chaninfo(userlist, handle, chname, par); if (par[0] == '@') dprintf(idx, "New info (LOCKED) for %s on %s: %s\n", handle, chname, &par[1]); else if (par[0]) dprintf(idx, "New info for %s on %s: %s\n", handle, chname, par); else dprintf(idx, "Wiped info for %s on %s\n", handle, chname); if (conf.bot->hub) write_userfile(idx); } else { set_user(&USERENTRY_INFO, u1, par[0] ? par : NULL); if (par[0] == '@') dprintf(idx, "New default info (LOCKED) for %s: %s\n", handle, &par[1]); else if (par[0]) dprintf(idx, "New default info for %s: %s\n", handle, par); else dprintf(idx, "Wiped default info for %s\n", handle); if (conf.bot->hub) write_userfile(idx); } }
static int script_channel_setinfo(struct userrec *u, char *channel_name, char *info) { if (!findchan_by_dname(channel_name)) return(-1); set_handle_chaninfo(userlist, u->handle, channel_name, info); return(0); }
static void cmd_info(int idx, char *par) { if (!use_info) { dprintf(idx, "Info storage is turned off.\n"); return; } char s[512] = "", *chname = NULL, *s1 = (char *) get_user(&USERENTRY_INFO, dcc[idx].user); bool locked = 0; if (s1 && s1[0] == '@') locked = 1; if (par[0] && strchr(CHANMETA, par[0])) { chname = newsplit(&par); if (!findchan_by_dname(chname)) { dprintf(idx, "No such channel.\n"); return; } get_handle_chaninfo(dcc[idx].nick, chname, s); if (s[0] == '@') locked = 1; s1 = s; } else chname = 0; if (!par[0]) { if (s1 && s1[0] == '@') s1++; if (s1 && s1[0]) { if (chname) { dprintf(idx, "Info on %s: %s\n", chname, s1); dprintf(idx, "Use 'info %s none' to remove it.\n", chname); } else { dprintf(idx, "Default info: %s\n", s1); dprintf(idx, "Use 'info none' to remove it.\n"); } } else dprintf(idx, "No info has been set for you.\n"); putlog(LOG_CMDS, "*", "#%s# info %s", dcc[idx].nick, chname ? chname : ""); return; } if (locked && !(dcc[idx].user && (dcc[idx].user->flags & USER_MASTER))) { dprintf(idx, "Your info line is locked. Sorry.\n"); return; } if (!strcasecmp(par, "none")) { if (chname) { par[0] = 0; set_handle_chaninfo(userlist, dcc[idx].nick, chname, NULL); dprintf(idx, "Removed your info line on %s.\n", chname); putlog(LOG_CMDS, "*", "#%s# info %s none", dcc[idx].nick, chname); } else { set_user(&USERENTRY_INFO, dcc[idx].user, NULL); dprintf(idx, "Removed your default info line.\n"); putlog(LOG_CMDS, "*", "#%s# info none", dcc[idx].nick); } return; } /* if (par[0] == '@') This is stupid, and prevents a users info from being locked */ /* par++; without .tcl, or a tcl script, aka, 'half-assed' -poptix 4Jun01 */ if (chname) { set_handle_chaninfo(userlist, dcc[idx].nick, chname, par); dprintf(idx, "Your info on %s is now: %s\n", chname, par); putlog(LOG_CMDS, "*", "#%s# info %s ...", dcc[idx].nick, chname); } else { set_user(&USERENTRY_INFO, dcc[idx].user, par); dprintf(idx, "Your default info is now: %s\n", par); putlog(LOG_CMDS, "*", "#%s# info ...", dcc[idx].nick); } }