def my_search_gl(args, message): query = " ".join(utils.m2list(args)).strip().casefold() res = [] for repo in gl.projects.list(owned=True, all=True): log(repo.name.casefold()) if query.casefold() in repo.name.casefold(): res.append(repo.web_url) return res
def my_search_gh(args, message): query = " ".join(utils.m2list(args)) res = [] for repo in gh.get_user().get_repos(): if query.casefold() in repo.name.casefold( ) and gh_owner == repo.owner.login: res.append(repo.html_url) return res
def add(args, message): nicks = utils.m2list(args) if message.sender_nick == ADMIN and MASTER: for nick in nicks: if nick in pids: return f"{message.sender_nick}: {nick} is already in use!" for nick in nicks: pids[nick] = subprocess.Popen( f"python3 /home/mattf/projects/ircbots/cbbot.py {shlex.quote(nick)} '{message.channel}'", stdout=subprocess.PIPE, shell=True)
async def send(bot: IrcBot, args, message): # If a handler is async, its first argument will be the bot itself args = utils.m2list(args) if len(args) < 3: return "Check help send" if not args[1].isdigit(): return "Delay argument should be integer and in seconds" utils.log("waiting") await bot.sleep(int(args[1])) #Wait for the delay # Sends the message. The channel can be also a username for private messages utils.log("sending") await bot.send_message(Message(channel=args[0], message=" ".join(args[2:])))
def _del(args, message): nicks = utils.m2list(args) output = [] if message.sender_nick == ADMIN: if NICK in nicks: sys.exit(0) if message.sender_nick == ADMIN and MASTER: for nick in nicks: if nick not in pids: output.append(f"{message.sender_nick}: {nick} is not in use!") continue pids[nick].kill() pids.pop(nick) return output
def echo(args, message): utils.log("echoing") return " ".join(utils.m2list(args)) # m2list converts a re.match to a list
def rainbow(args, message): utils.log("rainbowing") return "".join([Color(char, Color.random()).str for char in " ".join(utils.m2list(args))])
def fs(args, message): args = utils.m2list(args) query = " ".join(args) return gh_search(f"{query}")
def f2(args, message): args = utils.m2list(args) return gh_search(f"user:{args[0]}")
def f1(args, message): args = utils.m2list(args) query = " ".join(args[1:]) return gh_search(f"{query} language:{args[0]}")
def echo(args, message): return Color(" ".join(utils.m2list(args)), Color.random())