contrib.fun.coin
This commit is contained in:
		
							parent
							
								
									490b07d5b4
								
							
						
					
					
						commit
						92f4696a15
					
				
					 2 changed files with 14 additions and 2 deletions
				
			
		| 
						 | 
					@ -1,3 +1,5 @@
 | 
				
			||||||
 | 
					import random
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import dice
 | 
					import dice
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from butterrobot.plugins import Plugin
 | 
					from butterrobot.plugins import Plugin
 | 
				
			||||||
| 
						 | 
					@ -20,4 +22,13 @@ class DicePlugin(Plugin):
 | 
				
			||||||
    def on_message(cls, message: Message):
 | 
					    def on_message(cls, message: Message):
 | 
				
			||||||
        if message.text.startswith("!dice"):
 | 
					        if message.text.startswith("!dice"):
 | 
				
			||||||
            roll = int(dice.roll(message.text.replace("!dice ", "")))
 | 
					            roll = int(dice.roll(message.text.replace("!dice ", "")))
 | 
				
			||||||
            yield Message(chat=message.chat, reply_to=message.id, text=roll)
 | 
					            yield Message(chat=message.chat, reply_to=message.id, text=roll)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class CoinPlugin(Plugin):
 | 
				
			||||||
 | 
					    id = "contrib/fun/coin"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @classmethod
 | 
				
			||||||
 | 
					    def on_message(cls, message: Message):
 | 
				
			||||||
 | 
					        if message.text.startswith("!coin"):
 | 
				
			||||||
 | 
					            yield Message(chat=message.chat, reply_to=message.id, text=random.choice(("heads", "tails")))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,8 +30,9 @@ ipdb = "^0.13.2"
 | 
				
			||||||
[tool.poetry.plugins]
 | 
					[tool.poetry.plugins]
 | 
				
			||||||
[tool.poetry.plugins."butterrobot.plugins"]
 | 
					[tool.poetry.plugins."butterrobot.plugins"]
 | 
				
			||||||
"fun.loquito" = "butterrobot_plugins_contrib.fun:LoquitoPlugin"
 | 
					"fun.loquito" = "butterrobot_plugins_contrib.fun:LoquitoPlugin"
 | 
				
			||||||
"dev.ping" = "butterrobot_plugins_contrib.dev:PingPlugin"
 | 
					 | 
				
			||||||
"fun.dice" = "butterrobot_plugins_contrib.fun:DicePlugin"
 | 
					"fun.dice" = "butterrobot_plugins_contrib.fun:DicePlugin"
 | 
				
			||||||
 | 
					"fun.coin" = "butterrobot_plugins_contrib.fun:CoinPlugin"
 | 
				
			||||||
 | 
					"dev.ping" = "butterrobot_plugins_contrib.dev:PingPlugin"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[build-system]
 | 
					[build-system]
 | 
				
			||||||
requires = ["poetry>=0.12"]
 | 
					requires = ["poetry>=0.12"]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue