00001 /* ChanServ functions. 00002 * 00003 * (C) 2003-2012 Anope Team 00004 * Contact us at team@anope.org 00005 * 00006 * Please read COPYING and README for further details. 00007 * 00008 * Based on the original code of Epona by Lara. 00009 * Based on the original code of Services by Andy Church. 00010 */ 00011 00012 /*************************************************************************/ 00013 00014 #include "services.h" 00015 #include "anope.h" 00016 #include "regchannel.h" 00017 #include "users.h" 00018 #include "channels.h" 00019 #include "access.h" 00020 #include "account.h" 00021 00022 ChannelInfo* cs_findchan(const Anope::string &chan) 00023 { 00024 registered_channel_map::const_iterator it = RegisteredChannelList->find(chan); 00025 if (it != RegisteredChannelList->end()) 00026 { 00027 it->second->QueueUpdate(); 00028 return it->second; 00029 } 00030 00031 return NULL; 00032 } 00033 00034 /*************************************************************************/ 00035 00041 bool IsFounder(const User *user, const ChannelInfo *ci) 00042 { 00043 if (!user || !ci) 00044 return false; 00045 00046 if (user->SuperAdmin) 00047 return true; 00048 00049 if (user->Account() && user->Account() == ci->GetFounder()) 00050 return true; 00051 00052 return false; 00053 } 00054 00055 /*************************************************************************/ 00056 00057 void update_cs_lastseen(User *user, ChannelInfo *ci) 00058 { 00059 if (!ci || !user) 00060 return; 00061 00062 AccessGroup u_access = ci->AccessFor(user); 00063 for (unsigned i = u_access.size(); i > 0; --i) 00064 u_access[i - 1]->last_seen = Anope::CurTime; 00065 } 00066 00067 /*************************************************************************/ 00068 00069 /* Returns the best ban possible for a user depending of the bantype 00070 value. */ 00071 00072 int get_idealban(const ChannelInfo *ci, User *u, Anope::string &ret) 00073 { 00074 Anope::string mask; 00075 00076 if (!ci || !u) 00077 return 0; 00078 00079 Anope::string vident = u->GetIdent(); 00080 00081 switch (ci->bantype) 00082 { 00083 case 0: 00084 ret = "*!" + vident + "@" + u->GetDisplayedHost(); 00085 return 1; 00086 case 1: 00087 if (vident[0] == '~') 00088 ret = "*!*" + vident + "@" + u->GetDisplayedHost(); 00089 else 00090 ret = "*!" + vident + "@" + u->GetDisplayedHost(); 00091 00092 return 1; 00093 case 2: 00094 ret = "*!*@" + u->GetDisplayedHost(); 00095 return 1; 00096 case 3: 00097 mask = create_mask(u); 00098 ret = "*!" + mask; 00099 return 1; 00100 00101 default: 00102 return 0; 00103 } 00104 } 00105
1.7.1