async def twitter_follow(self, ctx, user_name): """Follows a twitter user, new tweets will be posted in the channel the command was called! Example: .follow_twitter <username or link>""" if 'twitter.com' in user_name: user_name = user_name.split('/')[-1] channel_id = ctx.channel.id add_channel(channel_id) user = self.client.get_twitter_user(user_name) if user: add_twitter_to_db(user.id_str) else: await ctx.send(embed=error_embed( f'Twitter user `{escape_markdown(user_name)}` not found!')) added = add_twitter_channel_to_db(channel_id, user.id_str) if added: icon_url = user.profile_image_url display_name = user.name link = f'https://twitter.com/{user.screen_name}' msg = f'This channel will now receive updates when {display_name} tweets at {link}' embed = discord.Embed( title=f'Successfully followed {escape_markdown(display_name)}', description=escape_markdown(msg), color=discord.Color.blue()) embed.set_thumbnail(url=icon_url) await ctx.send(embed=embed) if user.id_str not in get_users_to_stream(): self.restart_stream() else: await ctx.send(embed=error_embed( f'Failed to follow twitter user `{escape_markdown(user_name)}`!' ))
async def follow_insta(self, ctx, user_name): """Follows an Instagram user in this channel. Example: `.follow_insta <username or link>`""" if 'instagram.com' in user_name: user_name = user_name.split('/')[-1] user = self.insta.get_user(user_name) try: if user['is_private']: await ctx.send(embed=error_embed('This user is private, and cannot be followed!')) return except Exception as e: print(e) user_id = user['user']['pk'] if not user_id: await ctx.send(embed=error_embed(f'No instagram user found called {escape_markdown(user_name)}!')) return add_insta_user_to_db(user_id) add_channel(ctx.channel.id) if not follow_insta_user_db(user_id, ctx.channel.id): await ctx.send(embed=error_embed(f'{escape_markdown(user_name)} is already followed in this channel!')) return name = user['user']['full_name'] link = f"https://www.instagram.com/{user['user']['username']}" embed = discord.Embed(title=f'Successfully followed {name}', description=f'This channel will now receive updates when {name} posts updates at {link}', color=INSTA_COLOUR) embed.set_thumbnail(url=user['user']['profile_pic_url']) await ctx.send(embed=embed)
async def follow_twitch(self, ctx, stream): """Follows a twitch stream in this channel! Live updates will be posted here. .follow_twitch <username or link>""" channel = ctx.channel.id if "twitch.tv" in stream: stream = stream.split("/")[-1].lower() else: stream = stream.lower() user = self.twitch.get_users(logins=stream) print(user) if not user: await ctx.send( embed=error_embed(f"Failed to find Twitch user {stream}!")) return for d in user["data"]: ayed = str(d["id"]) add_channel(channel) add_twitch_channel_to_db(ayed) followed = follow_twitch_channel_db(channel, ayed) if followed: display_name = d['display_name'] profile_image = d['profile_image_url'] link = f"https://www.twitch.tv/{d['login']}" msg = f'This channel will now receive updates on when {display_name} goes live at {link}' embed = discord.Embed( title=f'Successfully Followed {display_name}!', description=msg, color=discord.Color.purple()) embed.set_thumbnail(url=profile_image) await ctx.send(embed=embed) else: await ctx.send(embed=error_embed( f"Failed to follow {stream} in this channel!"))
async def add_auditing(self, ctx): """Adds auditing from this channel, as links are added to the bot, they will also be posted here so all new additions can be viewed.""" if not check_user_is_mod(ctx): await ctx.send(embed=permission_denied_embed()) return add_channel(ctx.channel.id) added = add_auditing_channel(ctx.channel.id) if added: des = 'Added this channel to the auditing list!' await ctx.send(embed=success_embed(des)) else: des = 'Channel already in auditing list!' await ctx.send(embed=error_embed(des))
def create_channel(): payload = request.get_json() channel_name = payload['channel'] try: if payload.get('private', False): cid = add_channel(db, None, channel_name, isPrivate=True) else: cid = add_channel(db, session['user_id'], channel_name) response = {'success': 'true', 'channel_id': cid} print(channel_name + " created successfully...") return jsonify(response) except ChannelExistsError as e: response = {'success': 'false', 'reason': 'Already exists'} return jsonify(response) except MaxChannelCreatedError as e: response = {'success': 'false', 'reason': 'Limit reached'} return jsonify(response)
async def follow_subreddit(self, ctx, subreddit): """Add a subreddit to follow in this server! The channel this command is invoked in will be used to post the new submission to the sub. Example: `.follow_subreddit <subreddit_name>`""" channel = ctx.channel.id subreddit = subreddit.lower() if '/r/' in subreddit: subreddit = subreddit.split('/r/')[-1] subreddit_id = get_subreddit_id(subreddit) if not subreddit_id: add_reddit(subreddit) subreddit_id = get_subreddit_id(subreddit) add_channel(channel) found = find_channel(channel) added = add_reddit_channel(found[0], subreddit_id[0]) if added: msg = f"Added {subreddit} to this channel!" await ctx.send(embed=success_embed(msg)) else: msg = f"Already added {subreddit} to this channel!" await ctx.send(embed=error_embed(msg))