How to use get_owner_id method in avocado

Best Python code snippet using avocado_python

music_bot.py

Source:music_bot.py Github

copy

Full Screen

...23 self.gachi_list = json.load(json_data)24 @commands.command()25 async def comeon(self, ctx, *, channel: discord.VoiceChannel=None):26 """ Joins a voice channel """27 if self.get_owner_id() is None or self.get_owner_id() == ctx.author.id:28 if ctx.channel.id == MusicBot.id_channel:29 if channel is None and ctx.author.voice is None:30 return await ctx.send("You are not connected to a voice channel.")31 channel = channel or ctx.author.voice.channel32 if ctx.voice_client:33 await ctx.voice_client.move_to(channel)34 else:35 await channel.connect() 36 self.set_owner(ctx.author.id)37 self.owner_last_channel = self.get_owner_channel()38 self.owner_last_id = self.get_owner_id()39 self.debuglog("comeon func")40 await asyncio.sleep(15) 41 if ctx.voice_client and ctx.voice_client.is_playing() == False: 42 if self.get_owner_id():43 await ctx.voice_client.disconnect()44 self.clr_owner()45 self.owner_last_channel = None46 self.owner_last_id = None47 else:48 await MusicBot.__isNotOwner(self, ctx)49 50 @commands.command()51 async def gachi(self, ctx):52 """ Plays a song from the gachi list """53 if self.__isOwner(ctx):54 song = random.choice(self.gachi_list)55 url = 'https://www.youtube.com/watch?v={}'.format(song['url'])56 await self.__yt(ctx, url)57 else:58 await MusicBot.__isNotOwner(self, ctx)59 @commands.command()60 async def yt(self, ctx, *, url):61 """ Play from the given url / search for a song """62 if self.get_owner_id() is None:63 self.set_owner(ctx.author.id)64 if ctx.author.id == self.get_owner_id():65 if ctx.author.voice is not None:66 if ctx.channel.id == MusicBot.id_channel:67 await self.__yt(ctx, url)68 else:69 await MusicBot.__isNotOwner(self, ctx)70 @commands.command()71 async def pause(self, ctx):72 """ Pauses current track """73 if self.__isOwner(ctx, False):74 if ctx.voice_client and ctx.voice_client.is_playing():75 ctx.voice_client.pause()76 else:77 await MusicBot.__isNotOwner(self, ctx)78 @commands.command()79 async def resume(self, ctx):80 """ Resumes current track """81 if self.__isOwner(ctx, False):82 if ctx.voice_client and ctx.voice_client.is_paused():83 ctx.voice_client.resume()84 else:85 await MusicBot.__isNotOwner(self, ctx)86 @commands.command()87 async def volume(self, ctx, volume: int):88 """Changes the player's volume """89 if ctx.channel.id == MusicBot.id_channel: 90 if ctx.voice_client is None:91 return await ctx.send("Not connected to a voice channel.")92 self.volume_lvl = volume / 10093 ctx.voice_client.source.volume = self.volume_lvl94 await ctx.send("Changed volume to {}%".format(volume))95 @commands.command()96 async def fuckyou(self, ctx):97 """ Stops and disconnects the bot from voice """98 if self.__isOwner(ctx, False):99 await ctx.voice_client.disconnect()100 self.clr_owner()101 else:102 await MusicBot.__isNotOwner(self, ctx)103 '''104 @commands.command()105 async def forward(self, ctx, second: int):106 if ctx.voice_client:107 player = ctx.voice_client.source108 print("playre: " +str(player))109 '''110 @gachi.before_invoke111 @yt.before_invoke112 async def __ensure_voice(self, ctx):113 channel = None114 if ctx.author.voice and ctx.author.voice.channel: 115 if not channel:116 try:117 channel = ctx.author.voice.channel118 except AttributeError:119 raise InvalidVoiceChannel('No channel to join. Please either specify a valid channel or join one.')120 vc = ctx.voice_client121 if channel:122 if vc:123 if vc.channel.id == channel.id:124 return125 try:126 await vc.move_to(channel)127 except asyncio.TimeoutError:128 raise VoiceConnectionError(f'Moving to channel: <{channel}> timed out.')129 else:130 try:131 await channel.connect()132 except asyncio.TimeoutError:133 raise VoiceConnectionError(f'Connecting to channel: <{channel}> timed out.')134 else:135 await ctx.send("You are not connected to a voice channel.")136 @commands.Cog.listener()137 async def on_voice_state_update(self, member, before, after):138 self.debuglog("Voice state has been changed.")139 self.upd_user_channel(member.id, after.channel)140 bot_channel = self.get_bot_channel(self.bot.user.id)141 if after.channel and (member.id == self.get_owner_id or member.id == self.owner_last_id):142 if member.voice.channel:143 if after.channel.id != self.owner_last_channel.id:144 self.debuglog("owner leave channel")145 self.clr_owner()146 147 self.debuglog("Get owner: " +str(self.get_owner_id()))148 if(self.get_owner_id() is None):149 if member.id == self.owner_last_id and after.channel.id == self.owner_last_channel.id and bot_channel and bot_channel.id == self.owner_last_channel.id: 150 self.debuglog("Owner reconnect")151 self.set_owner(member.id)152 elif member.id == self.get_owner_id():153 self.debuglog("owner disconnect voice")154 self.clr_owner()155 #if self.debug_log: self.print_users()156 @commands.Cog.listener()157 async def on_ready(self):158 members = self.bot.get_all_members()159 User.get_users(self,members)160 @commands.Cog.listener()161 async def on_member_join(self,member):162 self.add_user(member)163 @commands.Cog.listener()164 async def on_member_remove(self,member):165 self.remove_user(member.id)166 @yt.error167 async def yt_on_error(self, ctx, error):168 print('Error: ' + str(error))169 await ctx.send("error")170 async def __yt(self, ctx, url, silent=False):171 async with ctx.typing(): 172 player = await YTDLSource.from_url(173 url,174 loop=self.bot.loop,175 stream=False,176 volume=self.volume_lvl177 )178 ctx.voice_client.play(179 player,180 after=lambda e: print('Player error: %s' % e) if e else None181 )182 if not silent:183 self.owner_last_channel = self.get_owner_channel()184 self.owner_last_id = self.get_owner_id()185 await ctx.send(186 'Now playing: {0} [{1}]'.format(player.title, player.time)187 ) 188 fulltime = float(player.time.total_seconds())189 delay = float(player.time.total_seconds() + 5.0)190 self.debuglog("delay time(full,delay): {0} , {1}".format(fulltime, delay))191 if delay > 305:192 delay = 305193 self.debuglog("To be sleep thread...")194 await asyncio.sleep(delay)195 print("unsleep")196 if self.__checkVoiceState(ctx):197 await ctx.voice_client.disconnect()198 self.clr_owner()199 return200 else:201 self.debuglog("owner is not None or owner not change")202 if(delay < fulltime):203 await asyncio.sleep(fulltime - delay)204 if self.__checkVoiceState(ctx):205 await ctx.voice_client.disconnect()206 self.clr_owner()207 self.owner_last_channel = None208 self.owner_last_id = None209 async def __isNotOwner(self, ctx):210 await ctx.send("You are not the owner of the running command.")211 def __isOwner(self, ctx, SetOwner: bool = True):212 if SetOwner:213 if self.get_owner_id() is None:214 self.set_owner(ctx.author.id)215 if ctx.author.id == self.get_owner_id():216 if ctx.channel.id == MusicBot.id_channel:217 return True218 return False219 def __checkVoiceState(self, ctx):220 if ctx.voice_client and ctx.voice_client.is_playing() == False:221 return True222 else:...

Full Screen

Full Screen

pars.py

Source:pars.py Github

copy

Full Screen

...19array_id = [line.rstrip() for line in array_id]20def add_dir_for_photos():21 for i in array_id:22 os.mkdir(f'id{i}')23def get_owner_id():24 for owner_id in array_id:25 return owner_id26def write_json(data):27 # with open('photos.json', 'w') as file:28 with open(f'id{get_owner_id()}/' + 'photos.json', 'w') as file:29 json.dump(data, file, indent=2, ensure_ascii=False)30def get_largest(size_dict):31 if size_dict['width'] >= size_dict['height']:32 return size_dict['width']33 else:34 return size_dict['height']35def download_photo(url):36 for owner_id in array_id:37 r = requests.get(url, stream = True)38 filename = url.split('/')[-1]39 with open(f'id{get_owner_id()}/' + filename, 'wb') as file:40 for chunk in r.iter_content(4096):41 file.write(chunk)42def main():43 add_dir_for_photos()44 for owner_id in array_id:45 r = requests.get(base + method_api, params = {'access_token': token,46 'owner_id': owner_id,47 'v': version_app,48 'album_id': album_id,49 'photo_sizes': photo_sizes})50 write_json(r.json())51 photos = json.load(open(f'id{get_owner_id()}/' + 'photos.json'))['response']['items']52 for photo in photos:53 sizes = photo['sizes']54 max_size_url = max(sizes, key = get_largest)['url']55 download_photo(max_size_url)56if __name__ == '__main__':...

Full Screen

Full Screen

Entity.py

Source:Entity.py Github

copy

Full Screen

...4 self.id = id5 self.is_ai_object = False6 self.exist = True7 8 def get_owner_id(self):9 return self.owner_id10 11 def set_owner_id(self, id):12 self.owner_id = id13 14 def is_owned(self):15 return self.id != 016 17 def is_friend(self, other):18 return self.id == other.get_owner_id()19 20 def is_enemy(self):21 return self.id > 0 and self.id != other.get_owner_id()22 23 def get_id(self):24 return self.id25 26 def set_ai_object(self, ai):27 self.is_ai_object = ai28 29 def set_existe(self, ex):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful