⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 command.c

📁 打魔兽战网的都知道他是什么
💻 C
📖 第 1 页 / 共 5 页
字号:
	{ "/f"                  , _handle_friends_command },	{ "/friends"            , _handle_friends_command },	{ "/me"                 , _handle_me_command },	{ "/msg"                , _handle_whisper_command },	{ "/whisper"            , _handle_whisper_command },	{ "/w"                  , _handle_whisper_command },	{ "/m"                  , _handle_whisper_command },	{ "/status"             , _handle_status_command },	{ "/users"              , _handle_status_command },	{ "/who"                , _handle_who_command },	{ "/whois"              , _handle_whois_command },	{ "/whereis"            , _handle_whois_command },	{ "/where"              , _handle_whois_command },	{ "/whoami"             , _handle_whoami_command },	{ "/announce"           , _handle_announce_command },	{ "/beep"               , _handle_beep_command },	{ "/nobeep"             , _handle_nobeep_command },	{ "/version"            , _handle_version_command },	{ "/copyright"          , _handle_copyright_command },	{ "/warrenty"           , _handle_copyright_command },	{ "/license"            , _handle_copyright_command },	{ "/uptime"             , _handle_uptime_command },	{ "/stats"              , _handle_stats_command },	{ "/astat"              , _handle_stats_command },	{ "/time"               , _handle_time_command },        { "/channel"            , _handle_channel_command },	{ "/join"               , _handle_channel_command },	{ "/rejoin"             , _handle_rejoin_command },	{ "/away"               , _handle_away_command },	{ "/dnd"                , _handle_dnd_command },	{ "/ignore"             , _handle_squelch_command },	{ "/squelch"            , _handle_squelch_command },	{ "/unignore"           , _handle_unsquelch_command },	{ "/unsquelch"          , _handle_unsquelch_command },//	{ "/designate"          , _handle_designate_command }, Obsotele command [Omega]//	{ "/resign"             , _handle_resign_command }, Obsolete command [Omega]	{ "/kick"               , _handle_kick_command },	{ "/ban"                , _handle_ban_command },	{ "/unban"              , _handle_unban_command },	{ "/tos"              , _handle_tos_command },	{ NULL                  , NULL }};static const t_command_table_row extended_command_table[] ={	{ "/ann"                , _handle_announce_command },	{ "/r"                  , _handle_reply_command },	{ "/reply"              , _handle_reply_command },	{ "/realmann"           , _handle_realmann_command },	{ "/watch"              , _handle_watch_command },	{ "/unwatch"            , _handle_unwatch_command },	{ "/watchall"           , _handle_watchall_command },	{ "/unwatchall"         , _handle_unwatchall_command },	{ "/lusers"             , _handle_lusers_command },	{ "/news"               , _handle_news_command },	{ "/games"              , _handle_games_command },	{ "/channels"           , _handle_channels_command },	{ "/chs"                , _handle_channels_command },	{ "/addacct"            , _handle_addacct_command },	{ "/chpass"             , _handle_chpass_command },	{ "/connections"        , _handle_connections_command },	{ "/con"                , _handle_connections_command },	{ "/finger"             , _handle_finger_command },	{ "/operator"           , _handle_operator_command },	{ "/aop"		, _handle_aop_command },	{ "/op"           	, _handle_op_command },	{ "/tmpop"           	, _handle_tmpop_command },	{ "/deop"           	, _handle_deop_command },	{ "/voice"		, _handle_voice_command },	{ "/devoice"		, _handle_devoice_command },	{ "/vop"		, _handle_vop_command },	{ "/admins"             , _handle_admins_command },	{ "/logout"             , _handle_quit_command },	{ "/quit"               , _handle_quit_command },	{ "/exit"               , _handle_quit_command },	{ "/kill"               , _handle_kill_command },	{ "/killsession"        , _handle_killsession_command },	{ "/gameinfo"           , _handle_gameinfo_command },	{ "/ladderactivate"     , _handle_ladderactivate_command },	{ "/rehash"             , _handle_rehash_command },//	{ "/rank_all_accounts"  , _handle_rank_all_accounts_command },	{ "/shutdown"           , _handle_shutdown_command },	{ "/ladderinfo"         , _handle_ladderinfo_command },	{ "/timer"              , _handle_timer_command },	{ "/serverban"          , _handle_serverban_command },	{ "/netinfo"            , _handle_netinfo_command },	{ "/quota"              , _handle_quota_command },	{ "/lockacct"           , _handle_lockacct_command },	{ "/unlockacct"         , _handle_unlockacct_command },	{ "/flag"               , _handle_flag_command },	{ "/tag"                , _handle_tag_command },	{ "/help"               , handle_help_command },	{ "/mail"               , handle_mail_command },	{ "/ipban"              , handle_ipban_command }, // in ipban.c	{ "/set"                , _handle_set_command },	{ "/motd"               , _handle_motd_command },	{ "/latency"            , _handle_ping_command },	{ "/ping"               , _handle_ping_command },	{ "/p"                  , _handle_ping_command },	{ "/commandgroups"	, _handle_commandgroups_command },	{ "/cg"			, _handle_commandgroups_command },	{ "/topic"		, _handle_topic_command },	{ "/moderate"		, _handle_moderate_command },	{ "/clearstats"		, _handle_clearstats_command },        { NULL                  , NULL }};char const * skip_command(char const * org_text){   unsigned int i;   char * text = (char *)org_text;   for (i=0; text[i]!=' ' && text[i]!='\0'; i++); /* skip command */   if (text[i]!='\0') text[i++]='\0';             /* \0-terminate command */   for (; text[i]==' '; i++);   return &text[i];}extern int handle_command(t_connection * c,  char const * text){  t_command_table_row const *p;  for (p = standard_command_table; p->command_string != NULL; p++)    {      if (strstart(text, p->command_string)==0)        {	  if (!(command_get_group(p->command_string)))	    {	      message_send_text(c,message_type_error,c,"This command has been deactivated");	      return 0;	    }	  if (!((command_get_group(p->command_string) & account_get_command_groups(conn_get_account(c)))))	    {	      message_send_text(c,message_type_error,c,"This command is reserved for admins.");	      return 0;	    }	if (p->command_handler != NULL) return ((p->command_handler)(c,text));	}    }    if (prefs_get_extra_commands()==0)    {	message_send_text(c,message_type_error,c,"Unknown command.");	eventlog(eventlog_level_debug,__FUNCTION__,"got unknown standard command \"%s\"",text);	return 0;    }    for (p = extended_command_table; p->command_string != NULL; p++)      {      if (strstart(text, p->command_string)==0)        {	  if (!(command_get_group(p->command_string)))	    {	      message_send_text(c,message_type_error,c,"This command has been deactivated");	      return 0;	    }	  if (!((command_get_group(p->command_string) & account_get_command_groups(conn_get_account(c)))))	    {	      message_send_text(c,message_type_error,c,"This command is reserved for admins.");	      return 0;	    }	if (p->command_handler != NULL) return ((p->command_handler)(c,text));	}    }    if (strlen(text)>=2 && strncmp(text,"//",2)==0)    {	handle_alias_command(c,text);	return 0;    }    message_send_text(c,message_type_error,c,"Unknown command.");    eventlog(eventlog_level_debug,__FUNCTION__,"got unknown command \"%s\"",text);    return 0;}// +++++++++++++++++++++++++++++++++ command implementations +++++++++++++++++++++++++++++++++++++++static int _handle_clan_command(t_connection * c, char const * text){  t_account * acc;  t_clanmember * member;  t_clan * clan;  text = skip_command(text);  if ( text[0] == '\0' )    {      message_send_text(c,message_type_info,c,"usage:");      message_send_text(c,message_type_info,c,"/clan public  /clan pub");      message_send_text(c,message_type_info,c,"Opens the clan channel up to the public so that anyone may enter.");      message_send_text(c,message_type_info,c,"/clan private  /clan priv");      message_send_text(c,message_type_info,c,"Closes the clan channel such that only members of the clan may enter.");      message_send_text(c,message_type_info,c,"/clan motd MESSAGE");      message_send_text(c,message_type_info,c,"Update the clan message of the day to MESSAGE.");      return 0;    }  if((acc = conn_get_account(c)) && (member = account_get_clanmember(acc)) && (clan = clanmember_get_clan(member)))  {    if(clanmember_get_status(member)>=CLAN_SHAMAN)    {      if (strstart(text,"public")==0 || strstart(text,"pub")==0) {        if(clan_get_channel_type(clan)!=0)        {          clan_set_channel_type(clan,0);          message_send_text(c,message_type_info,c,"Clan channel is opened up!");        }        else          message_send_text(c,message_type_error,c,"Clan channel has already been opened up!");      }      else      if (strstart(text,"private")==0 || strstart(text,"priv")==0) {        if(clan_get_channel_type(clan)!=1)        {          clan_set_channel_type(clan,1);          message_send_text(c,message_type_info,c,"Clan channel is closed!");        }        else          message_send_text(c,message_type_error,c,"Clan channel has already been closed!");      }      else      if (strstart(text,"motd")==0) {        const char * msg=skip_command(text);        if(msg[0]=='\0')        {          message_send_text(c,message_type_info,c,"usage:");          message_send_text(c,message_type_info,c,"/clan motd MESSAGE");          message_send_text(c,message_type_info,c,"Update the clan message of the day to MESSAGE.");        }        else        {          clan_set_motd(clan, msg);          message_send_text(c,message_type_info,c,"Clan message of day is updated!");        }      }    }    else      message_send_text(c,message_type_error,c,"You are not the chieftain or shaman of clan!");  }  else    message_send_text(c,message_type_error,c,"You are not in a clan!");  return 0;}static int command_set_flags(t_connection * c){  return channel_set_userflags(c);}static int _handle_admin_command(t_connection * c, char const * text){    char const *	username;    char		command;    t_account *		acc;    t_connection *	dst_c;    int			changed=0;    text = skip_command(text);    if ((text[0]=='\0') || ((text[0] != '+') && (text[0] != '-'))) {	message_send_text(c,message_type_info,c,"usage: /admin +username to promote user to Server Admin.");	message_send_text(c,message_type_info,c,"       /admin -username to demote user from Server Admin.");	return -1;    }    command = text[0];    username = &text[1];    if(!*username) {	message_send_text(c,message_type_info,c,"You need to supply a username.");      return -1;    }    if(!(acc = accountlist_find_account(username))) {	sprintf(msgtemp, "There's no account with username %.64s.", username);	message_send_text(c, message_type_info, c, msgtemp);	return -1;    }    dst_c = account_get_conn(acc);    if (command == '+') {	if (account_get_auth_admin(acc,NULL) == 1) {	    sprintf(msgtemp,"%s is already a Server Admin",username);	} else {	    account_set_auth_admin(acc,NULL,1);	    sprintf(msgtemp,"%s has been promoted to a Server Admin",username);	    sprintf(msgtemp2,"%s has promoted you to a Server Admin",conn_get_loggeduser(c));	    changed = 1;	}    } else {	if (account_get_auth_admin(acc,NULL) != 1)    	    sprintf(msgtemp,"%s is no Server Admin, so you can't demote him",username);	else {	    account_set_auth_admin(acc,NULL,0);	    sprintf(msgtemp,"%s has been demoted from a Server Admin",username);	    sprintf(msgtemp2,"%s has demoted you from a Server Admin",conn_get_loggeduser(c));	    changed = 1;	}    }    if (changed && dst_c) message_send_text(dst_c, message_type_info, c, msgtemp2);    message_send_text(c, message_type_info, c, msgtemp);    command_set_flags(dst_c);    return 0;}static int _handle_operator_command(t_connection * c, char const * text){    char const *	username;    char		command;    t_account *		acc;    t_connection *	dst_c;    int			changed = 0;    text = skip_command(text);    if ((text[0]=='\0') || ((text[0] != '+') && (text[0] != '-'))) {	message_send_text(c,message_type_info,c,"usage: /operator +username to promote user to Server Operator.");	message_send_text(c,message_type_info,c,"       /operator -username to demote user from Server Operator.");	return -1;    }    command = text[0];    username = &text[1];    if(!*username) {	message_send_text(c,message_type_info,c,"You need to supply a username.");      return -1;    }    if(!(acc = accountlist_find_account(username))) {	sprintf(msgtemp, "There's no account with username %.64s.", username);	message_send_text(c, message_type_info, c, msgtemp);	return -1;    }    dst_c = account_get_conn(acc);    if (command == '+') {	if (account_get_auth_operator(acc,NULL) == 1)	    sprintf(msgtemp,"%s is already a Server Operator",username);	else {	    account_set_auth_operator(acc,NULL,1);	    sprintf(msgtemp,"%s has been promoted to a Server Operator",username);	    sprintf(msgtemp2,"%s has promoted you to a Server Operator",conn_get_loggeduser(c));	    changed = 1;	}    } else {	if (account_get_auth_operator(acc,NULL) != 1)    	    sprintf(msgtemp,"%s is no Server Operator, so you can't demote him",username);	else {	    account_set_auth_operator(acc,NULL,0);	    sprintf(msgtemp,"%s has been demoted from a Server Operator",username);	    sprintf(msgtemp2,"%s has promoted you to a Server Operator",conn_get_loggeduser(c));	    changed = 1;	}    }    if (changed && dst_c) message_send_text(dst_c, message_type_info, c, msgtemp2);    message_send_text(c, message_type_info, c, msgtemp);    command_set_flags(dst_c);    return 0;}static int _handle_aop_command(t_connection * c, char const * text){    char const *	username;    char const *	channel;    t_account *		acc;    t_connection *	dst_c;    int			changed = 0;    if (!(conn_get_channel(c)) || !(channel = channel_get_name(conn_get_channel(c)))) {	message_send_text(c,message_type_error,c,"This command can only be used inside a channel.");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -