Giter Club home page Giter Club logo

dogehouse.py's Introduction

Welcome!

Hello there, I'm Arthur. A 20-year-old Freelance Software Engineering student at HOWEST University of Applied Sciences. I like to build solutions for problems I have/encounter online.

Currently interested in low level programming with rust.

Current Stack

* ordered from most important first

  • Rust [tokio, axum, poem-openapi]
  • Typescript [Svelte (&kit)]
  • SCSS
  • Neovim & Neovide, Jetbrains IDE's with VIM bindings
  • Unix (See .dotfiles repository for config)
  • Docker
  • Git
  • Figma

Technologies I know

Python, Java, Go, Javascript [including: prisma, vue, react (&NextJs), expressjs], sql, sqlite, cql (with scylladb), mssql, mysql, postgresql, C# (&.NET), php (&Laravel), Windows, Docker, Markdown, CSS (&derivates), Kotlin (&compose), Terraform, Ansible

Feel free to contact me on discord arthur_dw or mail me [email protected].

dogehouse.py's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dogehouse.py's Issues

Can't install using pip

    ERROR: Command errored out with exit status 1:
     command: 'c:\users\notmm\appdata\local\programs\python\python39\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\notmm\\AppData\\Local\\Temp\\pip-install-fi1zbmzm\\dogehouse_737517342ab24e0db7771551e779c185\\setup.py'"'"'; __file__='"'"'C:\\Users\\notmm\\AppData\\Local\\Temp\\pip-install-fi1zbmzm\\dogehouse_737517342ab24e0db7771551e779c185\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\notmm\AppData\Local\Temp\pip-pip-egg-info-k9zoptcf'
         cwd: C:\Users\notmm\AppData\Local\Temp\pip-install-fi1zbmzm\dogehouse_737517342ab24e0db7771551e779c185\
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
        from dogehouse import __version__
    ModuleNotFoundError: No module named 'dogehouse'
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/da/7e/19b4411d56da680704ab5c38dff93a3ef48c9bb4da844ce205ee96b89e37/dogehouse-0.0.0.tar.gz#sha256=8a8527596a5dcbe143f23eeb2da0b62632703c1abb274f3d75eb3b727db55044 (from https://pypi.org/simple/dogehouse/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement dogehouse
ERROR: No matching distribution found for dogehouse```

Things we need;

So, I'm new to Github and I don't know where to type comments so I'll issue it.
The things we need the most;

  1. A documentation for the module! I had to look through the source code to find what I need
  2. Functions that can do these things: "Make Mod", "Make Room Admin", "Ban from Chat", "Ban from Room"

on_permissions_change event

Hey, I'm not sure if we have an on__permissions_change event so we can detect when someone's permissions (admin, mod) have been changed

TypeError: object of type 'bool' has no len()

Describe the bug
When receiving a User's permissions, the represents function doesn't cast non-string objects to a string, instead, it casts string objects to a string, meaning the object will always be a non-string, causing an error.

To Reproduce
Steps to reproduce the behavior:

  1. Make a simple dogehouse bot
  2. Call __repr__ on User.room_permissions
  3. See error

And/or code:

from dogehouse import DogeClient, event, command
from dogehouse.entities import User

class Client(DogeClient):
    @event
    async def on_ready(self):
        pass

    @command
    async def test(self, ctx):
        user = await self.fetch_user(ctx.author.id)
        print(user.room_permissions.__repr__()) # You can exclude the __repr__ if you want

Expected behavior
A string printed in stdout, something along the lines of <Permission asked_to_speak='False' is_mod='False' is_admin='True' is_speaker='False'>

Screenshots
Screenshot from 2021-04-18 11-51-21

Desktop (please complete the following information):

  • OS: Manjaro Linux x86_64
  • Browser: Firefox
  • Version: 5.9.16-1-MANJARO

Additional context
You can solve this issue by swapping item and f"'{item}'" in line 52 of the /represents/representation.py file

Calling other functions doesn't work

Hey, not sure if this is my issue, but this didn't return an error in discord.py's variant, look;

  async def owner_check(authorid):
    ownerid = "de27447e-a633-484d-afaa-8377887dda7b"
    if authorid == ownerid:
      return True
    if authorid != ownerid:
      return False

  @command
  async def reboot(self, ctx: Message):
    await owner_check(authorid = ctx.author.id)
    if owner_check == True:
      await self.send("Rebooting the bot, I'll be back in 5 seconds!")
      await self.close()
      await asyncio.sleep(4)
      Client(DOGEHOUSE_TOKEN, DOGEHOUSE_REFRESH_TOKEN, prefix="d!", reconnect_voice=True).run()
      await asyncio.sleep(1)
      await self.send("I'm back online")
    else:
      return await self.send(f"{ctx.author.mention} You are not the owner of the bot so you may not reboot it!")

Error: NameError: name 'owner_check' is not defined

on_speaker_request event doesn't work?

This is my code, am I wrong??

   	 @event
     async def on_speaker_request(self, user: User):
         await self.send(f"🎤 Welcome to the stage - {user.username}")
         await self.add_speaker(user)

Error while installing dogehouse wrapper

    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\my_name\dogehousebot\env\Scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\my_name\\AppData\\Local\\Temp\\pip-install-303pxob6\\dogehouse\\setup.py'"'"'; __file__='"'"'C:\\Users\\my_name\\AppData\\Local\\Temp\\pip-install-303pxob6\\dogehouse\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\yc_la\AppData\Local\Temp\pip-pip-egg-info-qg1y2p5l'
         cwd: C:\Users\my_name\AppData\Local\Temp\pip-install-303pxob6\dogehouse\
    Complete output (11 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Usersmy_name\AppData\Local\Temp\pip-install-303pxob6\dogehouse\setup.py", line 3, in <module>
        from dogehouse import __version__
      File "C:\Users\my_name\AppData\Local\Temp\pip-install-303pxob6\dogehouse\dogehouse\__init__.py", line 24, in <module>
        from .client import DogeClient, event, command
      File "C:\Users\my_name\AppData\Local\Temp\pip-install-303pxob6\dogehouse\dogehouse\client.py", line 34, in <module>
        from .entities import User, Room, UserPreview, Message
      File "C:\Users\my_name\AppData\Local\Temp\pip-install-303pxob6\dogehouse\dogehouse\entities.py", line 27, in <module>
        from dateutil.parser import isoparse
    ModuleNotFoundError: No module named 'dateutil'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Convertors either don't work or I can't work with them

Hey, I'll leave the code I'm using at the bottom of the issue as it's long, I can't seem to get convertors working again, tell me what I'm doing wrong please

File "main.py", line 121, in testbattle
    if user.id == ctx.author.id:
AttributeError: 'str' object has no attribute 'id'

Code:

	@command
	async def testbattle(self, ctx: Message, *, user: BaseUser):
		if user == None:
			return await self.send(message=f"{ctx.author.mention} Missing Required Argument - Usage: d!battle <user> • Example: d!fight @hudson", whisper=[ctx.author.id])
		if user.id == ctx.author.id:
			return await self.send(message=f"{ctx.author.mention} Bad Argument (You cannot battle yourself) - Usage: d!battle <user> • Example: d!fight @hudson", whisper=[ctx.author.id])
		m_author_id = ctx.author.id
		m_user_id = user.id
		m_author_mention = ctx.author.mention
		m_user_mention = user.mention
		turn = random.choice([m_author_id, m_user_id])
		currenthpauth = 100
		currenthpuser = 100
		players = [m_author_id, m_user_id]
		moves = 0
		try:
			while True:
				if turn == m_author_id:
					currentturnid = m_author_id
					currentturnmention = m_author_mention
					currentturnhp = currenthpauth
					notturnid = m_user_id
					notturnmention = m_user_mention
					notturnhp = currenthpuser
				else:
					currentturnid = m_user_id
					currentturnmention = m_user_mention
					currentturnhp = currenthpuser
					notturnid = m_author_id
					notturnmention = m_author_mention
					notturnhp = currenthpauth
				await ctx.send(message=f"{currentturnmention}, what will you do now? • OPTIONS: Fight, Defense, Surrender • Your HP: {currentturnhp} HP, Your opponent's HP: {notturnhp} HP", whisper=currentturnid)
				msg = await self.wait_for(event=message, check=lambda message: msg.author.id == currentturnid)
				msgcont = msg.lower()
				if msgcont == 'fight':
					damage = random.randint(1,35)
					if damage == 35:
						damage = random.randint(35,75)
						dmgtext = f"{currentturnmention} made a critical hit of {damage} HP! :Pog:"
					else:
						dmgtext = f"{currentturnmention} chose violence. Damage of {damage} HP was given to {notturnmention}!"
					notturnhp -= damage
					await self.send(message=dmgtext, whisper=players)
					moves += 1
					if turn == m_author_id:
						turn = m_user_id
					else:
						turn = m_author_id
						
				elif msgcont == 'defense':
					healedhp = random.randint(5, 20)
					currentturnhp += healedhp
					if currentturnhp >= 100:
						currentturnhp = 100
					deftext = f"{currentturnmention} healed himself for {currentturnhp} HP!"
					await self.send(message=deftext, whisper=players)
					if turn == m_author_id:
						turn = m_user_id
					else:
						turn = m_author_id
				elif msgcont == 'surrender':
					await self.send(message=f"{currentturnmention} surrendered S :OMEGALUL:  BAD", whisper=players)
					return False
			
			if currenthpauth <= 0 or currenthpuser <= 0:
				if currenthpauth > currenthpuser:
					await self.send(f"{m_author_mention} has won against {m_user_mention} in {moves}! His remaining HP was {currenthpauth} HP.")
					return False
				elif currenthpuser > currenthpauth:
					await self.send(f"{m_user_mention} has won against {m_author_mention} in {moves}! His remaining HP was {currenthpuser} HP.")
					return False
			else:
				pass
		except Exception as e:
			print(e)

Default values don't work

IMG_20210326_172512

IMG_20210326_172445

This is the code that I'm using;

  @command
  async def pp(self, ctx: Message, *, user: User = None):
    print(user)
    if user == None:
      user2 = ctx.author.mention
      print(user)
    else:
      user2 = user.mention
    pps = [ I don't wanna make the code long so I'm not including the list ]
    
    pprnd = random.choice(pps)
      
    await self.send(f"{user2}'s pp: ㅤㅤㅤ{pprnd}")

Before the update, the tagging worked but obviously the ctx.author didn't, now it's vice-versa.

How could I use self.rooms?

Hey! How would I get info from this?
Because when I call self.rooms, I receive this biiiiig list and I can't seem to get stuff from it

[<Room id=ec61ca17-e38e-4c7... creator_id=f955b622-9a34-43e... name=Undead computer s... description= created_at=2021-04-05 09:16:48.457705+00:00 is_private=False count=18 users=[<UserPreview id=f955b622-9a34-43e... displayname=Null num_followers=158>, <UserPreview id=1755d9d9-2133-4fa... displayname=Bitdefender Antiv... num_followers=105>, <UserPreview id=7b0136c4-45ca-4ab... displayname=James num_followers=86>, <UserPreview id=f4c6eadb-9062-486... displayname=Honbra num_followers=61>, <UserPreview id=2fbb1c5d-2ce3-44e... displayname=Alt num_followers=39>, <UserPreview id=05bb4c2c-d321-4d2... displayname=DodgyCoin Bot num_followers=30>, <UserPreview id=5a050137-adec-4ce... displayname=Amine Maminou num_followers=23>, <UserPreview id=de27447e-a633-484... displayname=Asylum num_followers=19>, <UserPreview id=ab2e518f-3e63-45f... displayname=DogeBoss 🐶 num_followers=13>, <UserPreview id=77e4fb39-cc1b-4fd... displayname=Mubarak Showole num_followers=9>]>, <Room id=91b403ea-3615-481... creator_id=21b94c3c-c39a-4b5... name=AngularHaters description= created_at=2021-04-05 10:00:33.718604+00:00 is_private=False count=5 users=[<UserPreview id=21b94c3c-c39a-4b5... displayname=Jay Prakash Pathak num_followers=20>, <UserPreview id=17c0b799-c8bf-4ba... displayname=zrv num_followers=12>, <UserPreview id=6474331d-7359-406... displayname=dayum son num_followers=2>, <UserPreview id=6da6ec1e-a375-437... displayname=Rohin Awale num_followers=0>, <UserPreview id=34b54f15-d69d-4fc... displayname=Doob num_followers=0>]>, <Room id=cbcb2c9d-d982-417... creator_id=1d8a143c-22f2-4f3... name=Jerby Room  description=27 daily prayers ... created_at=2021-03-31 18:31:51.903058+00:00 is_private=False count=4 users=[<UserPreview id=e2f77c8d-afc5-490... displayname=Erwin DePanda num_followers=12>, <UserPreview id=1d8a143c-22f2-4f3... displayname=LJL num_followers=7>, <UserPreview id=d8fc5bbf-0ad3-4d2... displayname=Crashloll num_followers=6>, <UserPreview id=7f89041c-ac7d-469... displayname=Cengiz Gürtusgil num_followers=0>]>, <Room id=3fc0fe65-0b44-46f... creator_id=e44ad29a-536e-491... name=idk description= created_at=2021-04-04 21:06:15.910658+00:00 is_private=False count=3 users=[<UserPreview id=e44ad29a-536e-491... displayname=HoloPanio num_followers=108>, <UserPreview id=4aea3675-1b08-4e6... displayname=Novice Doge num_followers=10>, <UserPreview id=7c0059ff-f506-43f... displayname=Dave num_followers=0>]>, <Room id=c761eaf1-124b-47b... creator_id=704d82a0-ff97-40a... name=DMTK description= created_at=2021-04-05 09:46:54.172012+00:00 is_private=False count=2 users=[<UserPreview id=704d82a0-ff97-40a... displayname=DrFolleDinde num_followers=7>, <UserPreview id=063b3450-c06d-458... displayname=Novice Doge num_followers=2>]>, <Room id=2d7d56c4-7366-42d... creator_id=8b195657-f94f-45c... name=DoobHouse! description=GitHub.com/DoobDe... created_at=2021-04-04 17:38:38.553335+00:00 is_private=False count=1 users=[<UserPreview id=8b195657-f94f-45c... displayname=Doob num_followers=4>]>, <Room id=345e228b-ecff-4c9... creator_id=1b5cd5cf-a858-4c2... name=1 on 1 AI Chat description=The Bot will repl... created_at=2021-04-04 23:05:30.232612+00:00 is_private=False count=1 users=[<UserPreview id=1b5cd5cf-a858-4c2... displayname=daBOT num_followers=7>]>]

I tried self.rooms.name, self.rooms['name']

Still doesn't work

I'm trying to make a CLI

You cannot retrieve is_mod from BaseUser and User object

Describe the bug
You cannot get is_mod from the User / BaseUser object, look at screenshots.

To Reproduce
Steps to reproduce the behavior:
Try getting is_mod from User or BaseUser object, it returns an attribute error

And/or code:

	@command
	async def altcheck(self, ctx: Context):
		authormsg = ctx.author
		#authormsg = await self.convertuser(ctx.author.id)
		if authormsg.is_mod or authormsg.is_admin == True:
			pass
		else:
			return await self.send("You don't have permission to do that.", whisper=[ctx.author.id])
		await self.send("This may take a while, be patient.", whisper=[ctx.author.id])
		users = []
		for user in self.room.users:
			userdata = await self.returnavinfo(user)
			if userdata == "Twitter":
				continue
			else:
				users.append(userdata)
		
		userssend = "".join(users)
		await self.send(userssend, whisper=[ctx.author.id])

Expected behavior
It should return a boolean for is_mod.

Screenshots
IMG_20210409_203755
IMG_20210409_203703

Desktop (please complete the following information):

  • OS: [Android 10]
  • Browser [Brave]
  • Version [1.22.71]

Additional context
My DogeHouse.py version is 1.5.1

DogeHouse.py bot low uptime

Hey! Today I checked UptimeRobot to see stats on the Uptime of my Discord bots and my Dogehouse bot, I saw that the Dogehouse bot had a big difference in uptime
IMG_20210330_111126

Does that have something to do with the loop (that it's set to 30 minutes or smth) or is it just the socket disconnecting because it's not receiving anything?

NotEnoughArguments exception not called

Describe the bug
The NotEnoughArguments error doesn't get called

To Reproduce
Steps to reproduce the behavior:

  1. Try the command and event below without any arguments:
  2. The output is tuple index out of range instead of NotEnoughArguments

Expected behavior
The error should return NotEnoughArguments instead of tuple index out of range

Code

	@event
	async def on_error(self, error):
		print(error)
		if isinstance(error, dogehouse.exceptions.CommandNotFound):
			print("not found")
		elif isinstance(error, dogehouse.exceptions.NotEnoughArguments):
			print("yisiso")
		else:
			print("no")

	@command
	async def testerror(self, ctx: Context, tellemes):
		await self.send(tellemes)

Screenshots
IMG_20210420_102559

Desktop (please complete the following information):

  • OS: [linux]
  • Browser [replit ide bruh?]
  • Version [the newest i guess]
  • Is this stuff really needed? I don't think OS and browser matter really

Additional context
no

I fixed the problem it was just my pc

What should be added to the documentation?
Describe what you want to get implemented into the documentation.

Why should this be added to the documentation? Please describe
A clear reason why this should get implemented in the documentation.

We now can get fetch_user

Is your feature request related to a problem? Please describe.
n o

Describe the solution you'd like
We can now probably get a fetch_user feature because it is possible in the client, ex. in screenshot

Describe alternatives you've considered
I haven't considered any because there's only one way

Additional context
Screenshot_2021-04-17-18-22-46-587_com brave browser

BaseUser doesn't trigger if the argument ends with a whitespace

So, DogeHouse doesn't remove white spaces when a message has been sent with a space at the end, ex.;
d!fight @asylum , it wouldn't trigger because of the whitespace, so you'd have to remove the whitespace at the end for it to work.

I use BaseUser as my user arg. and I'm not sure if this happens with any other arg or if there's a way to fix that straight in your library or do I have to make an if endswith check in my code?

Getting IndentationError after added command aliases

Hey so, this happens after the update with aliases etc. may you have a look at what's going wrong please? Thanks ;)
error is IndentationError: unindent does not match any outer indentation level on the line @command, can't even run code, I put more code for reference;

class Client(DogeClient):
  @event
  async def on_ready(self):
    print(f"Successfully connected as {self.user}!")
    await self.join_room("d6046f84-28f2-4442-b6a1-28b53b3a6952")

  @command
  async def testifbroken(self, ctx: Message):
    await self.send(":Pog:")

Default set to None doesn't work

Hey so, I'm not sure if this is my problem but;

  @command
  async def covid(self, ctx: Message, *, country = None):
    if country == None:
      await self.send("You have to specify a country to see their COVID stats! Example: d!covid Czechia")
      return
    else:
      pass
    
    cases = Covid().get_status_by_country_name(country.lower())
    
    region = cases["country"]
    confirmed = cases["confirmed"]
    active = cases["active"]
    deaths = cases["deaths"]
    recovered = cases["recovered"]
    
    await self.send(f"COVID stats for {region} • Confirmed Cases: {confirmed} • Active Cases: {active} • Deaths: {deaths} • Recovered: {recovered}")

This is my command, it works normally but when the user doesn't specify the country, it should send the message "You have to specify a country..." but it doesn't, this works on Discord.py, not sure why it doesn't here! :D

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.