Commit e18c11814d7f7f805d4adac89573e5fe60524f09
- Diff rendering mode:
- inline
- side by side
Todo
(3 / 3)
|   | |||
| 28 | 28 | - [X] Send 10 last updates in private on request. | |
| 29 | 29 | - [X] Expand shortened URL's. Using http://www.longurl.org | |
| 30 | 30 | - [X] Display screenames along with real name on tweets. | |
| 31 | * Chanserv/Nickserv [0/7]: | ||
| 32 | - [ ] Identify with nickserv. | ||
| 31 | * Chanserv/Nickserv [2/7]: | ||
| 32 | - [X] Identify with nickserv. | ||
| 33 | 33 | - [ ] Identify with chanserv on joining channel. | |
| 34 | 34 | - [ ] Register nickname. | |
| 35 | 35 | - [ ] Register channel. | |
| 36 | 36 | - [ ] Kick ghosts using nickserv. | |
| 37 | 37 | - [ ] Ban/Unban users using chanserv. | |
| 38 | - [ ] Set user access depending on their current accesslevel on chanserv for certain channels. | ||
| 38 | - [X] Set user access depending on their current accesslevel on chanserv for certain channels. | ||
| 39 | 39 | * RSS [0/2] | |
| 40 | 40 | - [ ] Check if updated | |
| 41 | 41 | - [ ] Store last update |
kofoo.py
(4 / 3)
|   | |||
| 768 | 768 | else: | |
| 769 | 769 | print " - Module settings are of wrong type." | |
| 770 | 770 | if init_module: | |
| 771 | if init_module(self, sender): | ||
| 771 | if init_module(self, server, sender): | ||
| 772 | 772 | print " + Successfully initiated module '%s'." % module | |
| 773 | 773 | if sender: | |
| 774 | 774 | server.privmsg(sender, "Successfully loaded module '%s'." % module) | |
| … | … | ||
| 889 | 889 | """ [Native Command]""" | |
| 890 | 890 | for module in args: | |
| 891 | 891 | self.unload_module(server, module, irclib.nm_to_n(sender)) | |
| 892 | self.respond(server, sender, target, "Unloaded '%s'." % module) | ||
| 892 | 893 | ||
| 893 | 894 | def do_save(self, server, sender, target, args): | |
| 894 | 895 | """ [Native Command]""" | |
| … | … | ||
| 937 | 937 | config_file = arg | |
| 938 | 938 | ||
| 939 | 939 | irc = KoFoo() | |
| 940 | reconnected = 0 | ||
| 940 | reconnected = 1 | ||
| 941 | 941 | while not irc.want_to_quit: | |
| 942 | 942 | import time | |
| 943 | 943 | server = irc.server() | |
| … | … | ||
| 960 | 960 | irc.disconnect_all("Interrupted") | |
| 961 | 961 | print "Keyboard interruption captured." | |
| 962 | 962 | if irc.reconnect_timeout > 0: | |
| 963 | print "Wait for reconnection '%.2e'." % (irc.reconnect_timeout*reconnected) | ||
| 963 | print "Wait for reconnection '%.2f'." % (irc.reconnect_timeout*reconnected) | ||
| 964 | 964 | time.sleep(irc.reconnect_timeout*reconnected) | |
| 965 | 965 | reconnected -= 1 | |
| 966 | 966 | if reconnected < 0: |
kofoo_services.py
(74 / 15)
|   | |||
| 4 | 4 | ||
| 5 | 5 | services_settings = { 'channel_passwords': {} } | |
| 6 | 6 | ||
| 7 | owned_channels = [] | ||
| 8 | getting_alist_from = None | ||
| 9 | |||
| 7 | 10 | def init_services(bot, server, sender = None): | |
| 8 | 11 | if type(bot.settings.bot_channel_list) is dict: | |
| 9 | 12 | bot.settings.services_channel_passwords.extend(bot.settings.bot_channel_list) | |
| 10 | 13 | bot.settings.bot_channel_list = bot.settings.bot_channel_list.keys() | |
| 11 | 14 | ||
| 12 | identify_with_nickserv(bot, server, bot.settings.bot_nick_password) | ||
| 15 | identify_with_nickserv(bot, server) | ||
| 13 | 16 | ||
| 14 | 17 | for channel in bot.channel_list: | |
| 15 | 18 | identify_with_chanserv(bot, server, channel) | |
| 19 | request_access_list(bot, server, channel) | ||
| 20 | |||
| 21 | return True | ||
| 16 | 22 | ||
| 17 | 23 | def services_private_notice_handler(bot, server, sender, msg): | |
| 18 | 24 | if sender.lower() == "nickserv": | |
| 19 | handle_nickserv_notice(bot, server, msg) | ||
| 25 | return handle_nickserv_notice(bot, server, msg) | ||
| 20 | 26 | elif sender.lower() == "chanserv": | |
| 21 | handle_chanserv_notice(bot, server, msg) | ||
| 27 | return handle_chanserv_notice(bot, server, msg) | ||
| 22 | 28 | ||
| 29 | def services_join_part_handler(bot, server, channel, join): | ||
| 30 | if join: | ||
| 31 | ### Handle join event ### | ||
| 32 | identify_with_chanserv(bot, server, channel) | ||
| 33 | request_access_list(bot, server, channel) | ||
| 34 | else: | ||
| 35 | ### Handle part event ### | ||
| 36 | if channel in owned_channels: | ||
| 37 | owned_channels.remove(channel) | ||
| 38 | |||
| 23 | 39 | ## | |
| 24 | 40 | # End of module interface | |
| 25 | 41 | ##### | |
| … | … | ||
| 53 | 53 | else: | |
| 54 | 54 | print " - Has no password for '%s'." % channel | |
| 55 | 55 | ||
| 56 | |||
| 57 | 56 | def register_with_nickserv(bot, server, email): | |
| 58 | 57 | print "Register %s with nickserv." % bot.settings.bot_nick_name | |
| 59 | 58 | ||
| … | … | ||
| 64 | 64 | ||
| 65 | 65 | server.privmsg("chanserv", "op %s %s" % (channel, user)) | |
| 66 | 66 | ||
| 67 | def request_access_list(bot, server, channel): | ||
| 68 | """Ask chanserv for access list for channel.""" | ||
| 69 | print "Request access list for '%s'." % channel | ||
| 70 | |||
| 71 | server.privmsg("chanserv", "access %s list" % channel) | ||
| 72 | |||
| 67 | 73 | def handle_nickserv_notice(bot, server, msg): | |
| 68 | 74 | print "Notice from nickserv." | |
| 69 | 75 | if msg == "Your nickname isn't registered.": | |
| 70 | 76 | print " - Nickname not registered." | |
| 71 | 77 | bot.tell_users(server, "Nickname is not registered.", level=100, notice=True) | |
| 72 | 78 | #self.register_with_nickserv(self, server, self.settings.bot_nick_email) | |
| 73 | return | ||
| 79 | return True | ||
| 74 | 80 | ||
| 75 | 81 | if msg[:17] == "Password accepted": | |
| 76 | 82 | print " + Successfully identified with nickserv." | |
| 77 | 83 | bot.tell_users(server, "Successfully identified with nickserv.", level=100, notice=True) | |
| 78 | return | ||
| 84 | return True | ||
| 79 | 85 | ||
| 80 | 86 | res = re.match("STATUS (\S*) (\d)", msg) | |
| 81 | 87 | if res is not None: | |
| … | … | ||
| 95 | 95 | server.notice(user, "Command failed because you are not identified with nickserv.") | |
| 96 | 96 | if user in bot.on_user_id_do: | |
| 97 | 97 | del bot.on_user_id_do[user] | |
| 98 | return | ||
| 98 | return True | ||
| 99 | 99 | ||
| 100 | print " Unparsed message: %s" % msg | ||
| 100 | return False | ||
| 101 | 101 | ||
| 102 | 102 | def handle_chanserv_notice(bot, server, msg): | |
| 103 | 103 | """On private notice from chanserv, similar to nickserv.""" | |
| 104 | 104 | print "Notice from chanserv." | |
| 105 | 105 | ||
| 106 | res = re.match("Channel \\x02(.*)\\x02 isn't registered.", arg) | ||
| 106 | res = re.match('\s([0-9]{1,3})\s{2}(\S+)', msg) | ||
| 107 | 107 | if res is not None: | |
| 108 | try: | ||
| 109 | level = int(res.group(1)) | ||
| 110 | user = res.group(2) | ||
| 111 | users = bot.settings.bot_user_list | ||
| 112 | old_level = users.get(user, level) | ||
| 113 | level = max(level, old_level) | ||
| 114 | users[user] = level | ||
| 115 | print " + '%s' has been given the level '%d'." % (user, level) | ||
| 116 | return True | ||
| 117 | except Exception, e: | ||
| 118 | print " - Could not parse string '%s': %s" % (msg, str(e)) | ||
| 119 | return False | ||
| 120 | |||
| 121 | res = re.match("Channel \\x02(.*)\\x02 isn't registered.", msg) | ||
| 122 | if res is not None: | ||
| 108 | 123 | channel = res.group(1) | |
| 109 | 124 | print " + Channel %s is not registered." % channel | |
| 110 | 125 | self.tell_users(server, "Channel %s is not registered." % channel, level=100, notice=True) | |
| 111 | return | ||
| 126 | return True | ||
| 112 | 127 | ||
| 113 | res = re.match("Password accepted -- .* \\x02(.*)\\x02.", arg) | ||
| 128 | res = re.match("Password accepted -- .* \\x02(.*)\\x02.", msg) | ||
| 114 | 129 | if res is not None: | |
| 115 | 130 | channel = res.group(1) | |
| 116 | 131 | print " + Is taking control over %s." % channel | |
| 132 | owned_channels.append(channel) | ||
| 117 | 133 | self.make_op(server, channel, self.settings.bot_nick_name) | |
| 118 | 134 | self.tell_users(server, "Is taking control over %s." % channel, level=100, notice=True) | |
| 119 | return | ||
| 135 | return True | ||
| 120 | 136 | ||
| 121 | res = re.match("Opped \\x02(\S*)\\x02 on channel \\x02(\S*)\\x02.", arg) | ||
| 137 | res = re.match("Opped \\x02(\S*)\\x02 on channel \\x02(\S*)\\x02.", msg) | ||
| 122 | 138 | if res is not None: | |
| 123 | 139 | user = res.group(1) | |
| 124 | 140 | channel = res.group(2) | |
| … | … | ||
| 142 | 142 | print " + Control over %s established." % channel | |
| 143 | 143 | else: | |
| 144 | 144 | print " + %s has been opped on %s." % (user, channel) | |
| 145 | return | ||
| 145 | return True | ||
| 146 | 146 | ||
| 147 | print " %s" % arg | ||
| 147 | res = re.match('(\S+) access list is empty.', msg) | ||
| 148 | if res is not None: | ||
| 149 | channel = res.group(1) | ||
| 150 | print " + Got empty access list from '%s'." % channel | ||
| 151 | getting_alist_from = None | ||
| 152 | return True | ||
| 153 | |||
| 154 | res = re.match('Access list for (\S+):', msg) | ||
| 155 | if res is not None: | ||
| 156 | channel = res.group(1) | ||
| 157 | if channel in owned_channels: | ||
| 158 | getting_alist_from = channel | ||
| 159 | else: | ||
| 160 | print " - Got accesslist from unknown channel '%s'." % channel | ||
| 161 | return True | ||
| 162 | |||
| 163 | res = re.match('End of list; ([0-9]+)/([0-9]+) matches shown.', msg) | ||
| 164 | if res is not None: | ||
| 165 | print " + Got complete access list from '%s'." % str(getting_alist_from) | ||
| 166 | getting_alist_from = None | ||
| 167 | return True | ||
| 168 | |||
| 169 | return False |
kofoo_test.py
(2 / 2)
|   | |||
| 16 | 16 | update_test_delay = 60 | |
| 17 | 17 | update_test_time_left = 0 | |
| 18 | 18 | ||
| 19 | def init_test(bot, server_sender = None): | ||
| 19 | def init_test(bot, server, sender = None): | ||
| 20 | 20 | """Do things to initate the module and return True if | |
| 21 | 21 | successfull otherwise False.""" | |
| 22 | 22 | print " + Initiate Test module." | |
| 23 | 23 | return True | |
| 24 | 24 | ||
| 25 | def unload_test(bot, server_sender = None): | ||
| 25 | def unload_test(bot, server, sender = None): | ||
| 26 | 26 | """Do something on unloading the module.""" | |
| 27 | 27 | print " + Unload Test module." | |
| 28 | 28 | return True |

