/[weechat]/weechat/src/irc/irc-send.c
ViewVC logotype

Diff of /weechat/src/irc/irc-send.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.35 by flashcode, Sat Mar 12 20:08:08 2005 UTC revision 1.36 by flashcode, Sun Mar 13 23:36:47 2005 UTC
# Line 188  irc_cmd_send_away (t_irc_server *server, Line 188  irc_cmd_send_away (t_irc_server *server,
188  }  }
189    
190  /*  /*
191     * irc_cmd_send_ban: bans nicks or hosts
192     */
193    
194    int
195    irc_cmd_send_ban (t_irc_server *server, char *arguments)
196    {
197        char *pos_channel, *pos, *pos2;
198        
199        if (arguments)
200        {
201            pos_channel = NULL;
202            pos = strchr (arguments, ' ');
203            if (pos)
204            {
205                pos[0] = '\0';
206                
207                if (string_is_channel (arguments))
208                {
209                    pos_channel = arguments;
210                    pos++;
211                    while (pos[0] == ' ')
212                        pos++;
213                }
214                else
215                {
216                    pos[0] = ' ';
217                    pos = arguments;
218                }
219            }
220            else
221                pos = arguments;
222            
223            /* channel not given, use default buffer */
224            if (!pos_channel)
225            {
226                if (!BUFFER_IS_CHANNEL(gui_current_window->buffer))
227                {
228                    irc_display_prefix (server->buffer, PREFIX_ERROR);
229                    gui_printf_nolog (server->buffer,
230                                      _("%s \"%s\" command can only be executed in a channel window\n"),
231                                      WEECHAT_ERROR, "ban");
232                    return -1;
233                }
234                pos_channel = CHANNEL(gui_current_window->buffer)->name;
235            }
236            
237            /* loop on users */
238            while (pos && pos[0])
239            {
240                pos2 = strchr (pos, ' ');
241                if (pos2)
242                {
243                    pos2[0] = '\0';
244                    pos2++;
245                    while (pos2[0] == ' ')
246                        pos2++;
247                }
248                server_sendf (server, "MODE %s +b %s\r\n", pos_channel, pos);
249                pos = pos2;
250            }
251        }
252        else
253        {
254            if (!BUFFER_IS_CHANNEL(gui_current_window->buffer))
255            {
256                irc_display_prefix (server->buffer, PREFIX_ERROR);
257                gui_printf_nolog (server->buffer,
258                                  _("%s \"%s\" command can only be executed in a channel window\n"),
259                                  WEECHAT_ERROR, "ban");
260                return -1;
261            }
262            server_sendf (server, "MODE %s +b\r\n", CHANNEL(gui_current_window->buffer)->name);
263        }
264        
265        return 0;
266    }
267    
268    /*
269   * irc_cmd_send_ctcp: send a ctcp message   * irc_cmd_send_ctcp: send a ctcp message
270   */   */
271    
# Line 458  irc_cmd_send_join (t_irc_server *server, Line 536  irc_cmd_send_join (t_irc_server *server,
536  int  int
537  irc_cmd_send_kick (t_irc_server *server, char *arguments)  irc_cmd_send_kick (t_irc_server *server, char *arguments)
538  {  {
539      char *args, *pos;      char *pos_channel, *pos_nick, *pos_comment;
540            
541      if (string_is_channel (arguments))      if (string_is_channel (arguments))
         server_sendf (server, "KICK %s\r\n", arguments);  
     else  
542      {      {
543          if (BUFFER_IS_CHANNEL (gui_current_window->buffer))          pos_channel = arguments;
544            pos_nick = strchr (arguments, ' ');
545            if (!pos_nick)
546          {          {
547              args = strdup (arguments);              irc_display_prefix (server->buffer, PREFIX_ERROR);
548              pos = strchr (args, ' ');              gui_printf_nolog (server->buffer,
549              if (pos)                                _("%s wrong arguments for \"%s\" command\n"),
550                  pos[0] = '\0';                                WEECHAT_ERROR, "kick");
551              if (pos)              return -1;
                 server_sendf (server,  
                               "KICK %s %s :%s\r\n",  
                               CHANNEL(gui_current_window->buffer)->name, args, pos + 1);  
             else  
                 server_sendf (server,  
                               "KICK %s %s\r\n",  
                               CHANNEL(gui_current_window->buffer)->name, args);  
             free (args);  
552          }          }
553          else          pos_nick[0] = '\0';
554            pos_nick++;
555            while (pos_nick[0] == ' ')
556                pos_nick++;
557        }
558        else
559        {
560            if (!BUFFER_IS_CHANNEL(gui_current_window->buffer))
561          {          {
562              irc_display_prefix (server->buffer, PREFIX_ERROR);              irc_display_prefix (server->buffer, PREFIX_ERROR);
563              gui_printf_nolog (server->buffer,              gui_printf_nolog (server->buffer,
# Line 488  irc_cmd_send_kick (t_irc_server *server, Line 565  irc_cmd_send_kick (t_irc_server *server,
565                                WEECHAT_ERROR, "kick");                                WEECHAT_ERROR, "kick");
566              return -1;              return -1;
567          }          }
568            pos_channel = CHANNEL(gui_current_window->buffer)->name;
569            pos_nick = arguments;
570        }
571        
572        pos_comment = strchr (pos_nick, ' ');
573        if (pos_comment)
574        {
575            pos_comment[0] = '\0';
576            pos_comment++;
577            while (pos_comment[0] == ' ')
578                pos_comment++;
579        }
580        
581        if (pos_comment)
582            server_sendf (server, "KICK %s %s :%s\r\n", pos_channel, pos_nick, pos_comment);
583        else
584            server_sendf (server, "KICK %s %s\r\n", pos_channel, pos_nick);
585        
586        return 0;
587    }
588    
589    /*
590     * irc_cmd_send_kickban: forcibly remove a user from a channel and ban it
591     */
592    
593    int
594    irc_cmd_send_kickban (t_irc_server *server, char *arguments)
595    {
596        char *pos_channel, *pos_nick, *pos_comment;
597        
598        if (string_is_channel (arguments))
599        {
600            pos_channel = arguments;
601            pos_nick = strchr (arguments, ' ');
602            if (!pos_nick)
603            {
604                irc_display_prefix (server->buffer, PREFIX_ERROR);
605                gui_printf_nolog (server->buffer,
606                                  _("%s wrong arguments for \"%s\" command\n"),
607                                  WEECHAT_ERROR, "kickban");
608                return -1;
609            }
610            pos_nick[0] = '\0';
611            pos_nick++;
612            while (pos_nick[0] == ' ')
613                pos_nick++;
614      }      }
615        else
616        {
617            if (!BUFFER_IS_CHANNEL(gui_current_window->buffer))
618            {
619                irc_display_prefix (server->buffer, PREFIX_ERROR);
620                gui_printf_nolog (server->buffer,
621                                  _("%s \"%s\" command can only be executed in a channel window\n"),
622                                  WEECHAT_ERROR, "kickban");
623                return -1;
624            }
625            pos_channel = CHANNEL(gui_current_window->buffer)->name;
626            pos_nick = arguments;
627        }
628        
629        pos_comment = strchr (pos_nick, ' ');
630        if (pos_comment)
631        {
632            pos_comment[0] = '\0';
633            pos_comment++;
634            while (pos_comment[0] == ' ')
635                pos_comment++;
636        }
637        
638        server_sendf (server, "MODE %s +b %s\r\n", pos_channel, pos_nick);
639        if (pos_comment)
640            server_sendf (server, "KICK %s %s :%s\r\n", pos_channel, pos_nick, pos_comment);
641        else
642            server_sendf (server, "KICK %s %s\r\n", pos_channel, pos_nick);
643        
644      return 0;      return 0;
645  }  }
646    
# Line 1314  irc_cmd_send_trace (t_irc_server *server Line 1466  irc_cmd_send_trace (t_irc_server *server
1466      return 0;      return 0;
1467  }  }
1468    
1469    /*
1470     * irc_cmd_send_unban: unbans nicks or hosts
1471     */
1472    
1473    int
1474    irc_cmd_send_unban (t_irc_server *server, char *arguments)
1475    {
1476        char *pos_channel, *pos, *pos2;
1477        
1478        if (arguments)
1479        {
1480            pos_channel = NULL;
1481            pos = strchr (arguments, ' ');
1482            if (pos)
1483            {
1484                pos[0] = '\0';
1485                
1486                if (string_is_channel (arguments))
1487                {
1488                    pos_channel = arguments;
1489                    pos++;
1490                    while (pos[0] == ' ')
1491                        pos++;
1492                }
1493                else
1494                {
1495                    pos[0] = ' ';
1496                    pos = arguments;
1497                }
1498            }
1499            else
1500                pos = arguments;
1501            
1502            /* channel not given, use default buffer */
1503            if (!pos_channel)
1504            {
1505                if (!BUFFER_IS_CHANNEL(gui_current_window->buffer))
1506                {
1507                    irc_display_prefix (server->buffer, PREFIX_ERROR);
1508                    gui_printf_nolog (server->buffer,
1509                                      _("%s \"%s\" command can only be executed in a channel window\n"),
1510                                      WEECHAT_ERROR, "unban");
1511                    return -1;
1512                }
1513                pos_channel = CHANNEL(gui_current_window->buffer)->name;
1514            }
1515            
1516            /* loop on users */
1517            while (pos && pos[0])
1518            {
1519                pos2 = strchr (pos, ' ');
1520                if (pos2)
1521                {
1522                    pos2[0] = '\0';
1523                    pos2++;
1524                    while (pos2[0] == ' ')
1525                        pos2++;
1526                }
1527                server_sendf (server, "MODE %s -b %s\r\n", pos_channel, pos);
1528                pos = pos2;
1529            }
1530        }
1531        else
1532        {
1533            irc_display_prefix (server->buffer, PREFIX_ERROR);
1534            gui_printf_nolog (server->buffer,
1535                              _("%s wrong argument count for \"%s\" command\n"),
1536                              WEECHAT_ERROR, "unban");
1537            return -1;
1538        }
1539        
1540        return 0;
1541    }
1542    
1543  /*  /*
1544   * irc_cmd_send_userhost: return a list of information about nicknames   * irc_cmd_send_userhost: return a list of information about nicknames
1545   */   */

Legend:
Removed from v.1.35  
changed lines
  Added in v.1.36

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26