Giter VIP home page Giter VIP logo

dongerdong's Introduction

DongerDong

What started as "A simple IRC bot for fighting, written in Python" has grown to become the most comprehensive and flexible collection of code ever written.

Official IRC Channel: #donger on Libera (irc.libera.chat)

Development Channel: #donger-dev on Libera (irc.libera.chat)

How to install

  • Install Python 3
  • Install requirements pyfiglet, peewee, pydle and pure-sasl (via pip install -r requirements.txt if you want, you're an adult it's your call)
  • Rename config.example to config.json and edit it
  • Configure the IRC user and channel:
    • Register the username and nickname the bot will be using with NickServ (the ones you set in config.json)
    • Register the primary channel the bot will be using, and ensure the bot has flags of at least +Oefr in that channel's access list. It needs to receive channel op when joining the channel, and must be able to set AKICKs with ChanServ (for deathmatches)
  • Run the bot (with Python 3)
  • ???
  • Profit!

Configuration Notes

  • server is the server you're connecting to
  • nick is the nickname the bot will request when connecting to the server
  • channel is the bot's "primary channel" - the one where all the fighting happens
  • port is the port to connect over, default is 6697
  • tls defines whether we're doing the connection securely (default is true)
  • nickserv_username and nickserv_password specify the credentials the bot will send to nickserv to identify
  • auxchans are additional, non-fighting channels the bot joins on connect. These channels have access to fewer commands, and messages to them are limited by a (basic) flood control system. Enter channels in the format ["#channel1","#channel2"], etc.
  • extendedcommands references files of the same name in the "extcmd" folder. Try adding "update" to enable the update.py extended command.
  • topmodifier changes the way players are ranked depending on how many fights they've participated in. Defaults to 0.05.
  • admins specifies the usernames of people with additional permissions - like !join, !part, and (if enabled through extended commands) !update.
  • stats-url is optional and can be removed entirely if you don't have a URL where statistics are displayed (the Supreme Dongerdong's statistics page is set as default, but will not display statistics from your instance).
  • show-ascii-art-text is an accessibility feature. When set to false, it does not send ASCII text art to channels, instead printing the text normally.

Wisdom

All that is gold does not glitter,
Not all those who donger are lost;
The old that do dong do not wither,
Deep dongs are not reached by the frost.
From the ashes the donger shall be woken,
A light from the shadows shall spring;
Renewed shall be blade that was broken,
The donger again shall be king
-J.R.R. Tolkien

"He who learns but does not think, is lost! He who dongs dongs, dongs dongs!" - Confucius

dongerdong's People

Contributors

greykiteshield avatar mtfd avatar polsaker avatar tonyravioli avatar vgr255 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dongerdong's Issues

!stats is broken

!stats doesn't pull anyone's stats anymore :(

!top still does.

Stats Feature

Add feature to parse CSV located at http://ravio.li/donger/stats.txt. Should:

  1. Retrieve that list once, unless there have been no fights since stats were last retrieved (in that instance, use cached copy)
  2. Parse it to provide answers to these commands:
  • !leaderboard (or something like that) - spits out the three people with the most wins
  • !mystats (or something hopefully better) - spits out the user's wins vs losses.

Exception thrown when you ask for stats for an account name rather than a nick

Log:

DEBUG:bearded-potato-donger:command: pubmsg, source: ravioli!~ravioli@unaffiliated/ravioli, target: #donger, arguments: ['!stats MRX']
Unhandled exception in thread started by <bound method Donger._pubmsg of <__main__.Donger object at 0x22ee610>>
Traceback (most recent call last):
  File "./dongerdong.py", line 374, in _pubmsg
    if cli.channels[ev.target.lower()].users[nick.lower()].account != None:
KeyError: 'mrx'

What's up with that "!= None" thing? I don't even know what that line's doing.

More deathmatch glitches

09:42 (      challenger ) !deathmatch newb 
09:42 (@     dong ) newb: challenger has challenged you to a deathmatch. The loser will be bant for 20 minutes. To accept, use '!accept challenger'
09:42 (   me ) wait wait...
09:42 (   me ) hold up
09:42 (   me ) !stats newb
09:42 (@     dong ) There are no registered stats for newb
09:43 (   me ) challenger: just do regular !fight
09:43 (      challenger ) :|
09:43 (   me ) don't wanna kill him on first fight, eh?
09:43 (      challenger ) !fight newb 
09:43 (@     dong ) newb: challenger has challenged you. To accept, use '!accept challenger'
09:43 (      challenger ) !stats
09:43 (@     dong ) challenger's stats: 16 wins, 1 easy wins, 16 losses, 0 coward quits, 0 idle-outs, 3 !praises, 21 fights started, accepted 10 fights (31 total 
                    fights), 167 !hits, 80 !heals, 4973HP of damage dealt and 5013 damage received. http://www.donger.org/stats/
09:43 (  newb ) !accept challenger 
09:43        dong ª set [+m] in #donger
09:43 (@     dong )    ___  _______ ________ ____  ______ _____________ __
09:43 (@     dong )   / _ \/ __/ _ /_  __/ // /  |/  / _ /_  __/ ___/ // /
09:43 (@     dong )  / // / _// __ |/ / / _  / /|_/ / __ |/ / / /__/ _  / 
09:43 (@     dong ) /____/___/_/ |_/_/ /_//_/_/  /_/_/ |_/_/  \___/_//_/  

akick won't work in this sceneraio.

In #donger on freenode, User rotta666 and I have been doing deathmatches, and we both recieve instakills. After getting kicked, we were able to rejoin the channel, which i found odd, since it was a deathmatch. Upon closer inspection, it appears as though it is because akick doesn't work on +r (registered) users. However, it still bans just fine on deathmatches with no instakill. If you would like to assign this issue to me I would be more than happy to dig through my fork and find it.

Consolidate voice/devoice commands

Currently the bot issues one voice/devoice command per user, like this:

dong sets mode +v user1
dong sets mode +v user2

IRC supports this, which is much cleaner:

dong sets mode +vv user1 user2

Alter !top command to list based on kill-to-death

!top currently pulls people who have the most wins. It should order by kill-to-death ratio. Currently, if we had a user with 300 losses and 30 wins, they'd be considered the "top" player.

It should only include people who have participated in more than X fights (5? 10?) to prevent someone who has only 3 fights (2 wins, 1 loss) from dominating the leaderboard.

Add verbose mode

Add verbose mode, enabled by:

!fight --verbose
or
!fight -v

Where verbose mode outputs all math on hits.

!ping

Create a !ping feature to allow bot to /ping the requesting user, and have bot output ping result back to user.

<user> !ping
<bot>  user: 0.577 seconds

Create a system for modular scripts

For instance, a folder called scripts, with a file like jaden.py. A user calls !jaden, which isn't a command specified in the main dongerdong.py script, but IS defined in that jaden.py file.

except keyboardinterrupt on break

while dongerdong.irc.connected == True:
    time.sleep(1) # Infinite loop of awesomeness

to:

while dongerdong.irc.connected == True:
    try:
        time.sleep(1) # Infinite loop of awesomeness
    except KeyboardInterrupt:
        say some witty thing to chan
        print "exit due to keyboard interrupt" to stdout
        exit with error code 0

nasty error

Traceback (most recent call last):
  File "./dongerdong.py", line 201, in _pubmsg
    self.fight(cli, self.pending[ev.splitd[1]], ev.splitd[1], self.deathmatch)
  File "./dongerdong.py", line 697, in fight
    self.prefight()
TypeError: fakeprefight() takes exactly 1 argument (0 given)

why isn't it passing self? that's odd

Dongcoin values and functionality

I'm thinking...

  • 5 for a win in 1v1
  • 2 for each kill in a game with more than two players
  • 10 for a deathmatch win

Betting:

player1>!fight player2
player2>!accept player1
(intro to match)
PLACE BETS NOW
(sleep for 10 seconds while
players /msg dong bets:
    /msg dong !bet 20 on player1
dong announces bets as they come in)
FIGHT ascii
(betting closes on first !hit)

if no opposing bets are placed:
    cancel bets
else:
    calculate percentages of bets placed by multiple people on each player (i.e. on player 1: polsaker 60% of bet, ravioli 20% of bet, otherperson 20% of bet)
    use lowest total (so if there's 10 coin on player2 and 50 coin on player1, max payout (total) for all players is 10)

at the end of the fight, payout depending on percentages. so in the above example, if player1 wins, polsaker gets 6 coin, ravioli gets 2, and otherperson gets 2.

Expire Old Bounties

Bounties that don't expire will pile up and become lost coins forever in purgatory and clutter up !wanted.
Time frames could be a few days or a few weeks.

Timeout handler

Restart or reconnect bot if a ping request isn't heard from server after a certain amount of time. Useful for places like my server, where apparently it loses connection every night.

Improve fight AI

Improve the bot's fight AI. It's currently too easy to beat the Supreme Dongerdong.

The bot must play fair.

Idles and quits should count as deaths...

...with the credit for the kill being awarded to the person's opponent (or the last person to hit them if it's multi-player). I think that's working now (giving easy wins), but they should be kicked as well (which isn't happening now).

Idles and quits in deathmatches should cause a bant (just like if they lost the normal way), but should also incur a fine of 10 dongcoins (to be given to the victor, along with the normal 10 coins for winning).

Allow user to fight bot

Create functionality for the bot to fight the user, !healing itself and !hitting the other player depending on probabilities. If it loses, bot should kick itself after (if possible) and rejoin automatically.

Allow bot to provide different functions in a non-fight-channel environment.

Allow bot to join two channels:

  • fightchannel
  • anotherchannel

where functions in fightchannel are what we have now, and functions in anotherchannel include basic bot functions (weather, "botname!", etc.) in a plugin-based setup. For instance, dongerdong can use #donger as fightchannel and #crude as anotherchannel.

Ideally, bot can announce fights that are commencing in fightchannel, by telling anotherchannel. Bot will announce winners and losers at the conclusion of each fight, and the behavior of the bot can be configured by any user with ops in anotherchannel ("botname, stop", "botname, start").

dongerdong can't handle switching accounts

Raw log

 PRIVMSG #donger :!fight rika
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+rika: heidemann has challenged you. To accept, use '!accept heidemann'
>> :rika!rika@trivialand/guesser/rika PRIVMSG #donger :+!accept heidemann
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong MODE #donger +m 
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+ __                         __  __  __                 
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+|__)||_/ /\   \  /     |__||_ ||  \|_ |\/| /\ |\ ||\ | 
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+| \ || \/--\   \/ .    |  ||__||__/|__|  |/--\| \|| \| 
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+RULES:
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+1. Wait your turn. One person at a time.
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+2. Be a dick about it.
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+ 
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+Use !hit [nick] to strike.
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+Use !heal to heal yourself.
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+Use !praise [nick] to praise to the donger gods (once per game).
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+Use '/msg dong !join' to join a game mid-fight.
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+ 
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+   _______________ ________
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+  / __/  _/ ___/ // /_  __/
<< PING LAG1430804161043
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+ / _/_/ // (_ / _  / / /   
>> :wolfe.freenode.net PONG wolfe.freenode.net :LAG1430804161043
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+/_/ /___/\___/_//_/ /_/    
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong MODE #donger +vv rika heidemann
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+It is rika's turn
<< PRIVMSG nickserv :identify rika 
>> :NickServ!NickServ@services. NOTICE heidemann :+You have been logged out of filicia.
>> :NickServ!NickServ@services. NOTICE heidemann :+You are now identified for rika.
>> :wolfe.freenode.net 396 heidemann trivialand/guesser/rika :is now your hidden host (set by services.)
>> :ChanServ!ChanServ@services. MODE #donger -v heidemann
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+  _________ _      _____   ___  ___ 
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+ / ___/ __ \ | /| / / _ | / _ \/ _ \
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+/ /__/ /_/ / |/ |/ / __ |/ , _/ // /
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+\___/\____/|__/|__/_/ |_/_/|_/____/ 
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+The coward is dead!
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong MODE #donger -m 
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong MODE #donger -v rika
<< PRIVMSG #donger :!fight dong
>> :rika!rika@trivialand/guesser/rika PRIVMSG #donger :+!fight dong
>> :dong!~dong@unaffiliated/ravioli/bot/dongerdong PRIVMSG #donger :+YOU WILL SEE

notice lack of reaction on << PRIVMSG #donger :!fight dong

Some kind of weapon system

It's time to overcomplicate the game:
We could add some kind of weapon/shield system, assigning a random kit to every player when they !accept

Quoting Mithadon:

1 handed sword goes with shield so you have a chance to block but the sword is weaker than long sword, axe has a bigger variation from lowest to highest dmg dealt

!accept <notarealnickname> causes dongerdong to say the person won?

DEBUG:bearded-potato-donger::[email protected] PRIVMSG #donger :!accept nope
DEBUG:bearded-potato-donger:command: pubmsg, source: [email protected], target: #donger, arguments: ['!accept nope']
Unhandled exception in thread started by <bound method Donger._pubmsg of <__main__.Donger object at 0x1e1ac10>>
Traceback (most recent call last):
  File "./dongerdong.py", line 131, in _pubmsg
    cli.channels[self.chan].users[ev.splitd[1]]
KeyError: 'nope'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./dongerdong.py", line 134, in _pubmsg
    del self.pending[ev.splitd[1]]
KeyError: 'nope'
DEBUG:bearded-potato-donger:TO SERVER: PRIVMSG #donger :Err... Maybe you meant to say !fight nope? They never challenged you.
DEBUG:bearded-potato-donger:TO SERVER: PRIVMSG #donger :Well... They were cowards... YOU WIN
DEBUG:bearded-potato-donger::ravioli!~ravioli@unaffiliated/ravioli PRIVMSG #donger :wtf

!quit errors when no fight is in progress.

It should probably just do nothing when no fight is in progress.

Unhandled exception in thread started by <bound method Donger._pubmsg of <__main__.Donger object at 0x20aac10>>
Traceback (most recent call last):
  File "./dongerdong.py", line 208, in _pubmsg
    cli.mode(self.channel, "-v " + ev.source)
AttributeError: 'Donger' object has no attribute 'channel'

Nerf healing after a certain amount of heals

Cause the maximum heal to be negated by 8(?) hp every time someone uses !heal without using !hit. For instance, if a user just uses !heal for 3 turns in a row, the maximum heal will be 24 HP less than normal. Using !hit once(?) will reset that max heal HP.

Configurable bot owners with special permissions

Add configuration option in config.json for accounts which have owner permissions. We can use this to implement/allow special features like !flush to cancel all pending fights, or !cycle to restart the bot, for example.

"Owners" must be identified to services to be recognized.

Connection error?

I'm at work and can't troubleshoot right this second, but trying to run dongerdong, here's the output:

DEBUG:peewee:('SELECT name FROM sqlite_master WHERE type = ? ORDER BY name;', ('table',))
INFO:bearded-potato-donger:Connecting to irc.freenode.net:6667
ERROR:bearded-potato-donger:Couldn't connect to irc.freenode.net:6667: [Errno 111] Connection refused
INFO:bearded-potato-donger:Connecting to irc.freenode.net:6667
ERROR:bearded-potato-donger:Couldn't connect to irc.freenode.net:6667: [Errno 111] Connection refused
INFO:bearded-potato-donger:Connecting to irc.freenode.net:6667
ERROR:bearded-potato-donger:Couldn't connect to irc.freenode.net:6667: [Errno 111] Connection refused
INFO:bearded-potato-donger:Connecting to irc.freenode.net:6667
ERROR:bearded-potato-donger:Couldn't connect to irc.freenode.net:6667: [Errno 111] Connection refused
INFO:bearded-potato-donger:Connecting to irc.freenode.net:6667
ERROR:bearded-potato-donger:Couldn't connect to irc.freenode.net:6667: [Errno 111] Connection refused
INFO:bearded-potato-donger:Connecting to irc.freenode.net:6667
ERROR:bearded-potato-donger:Couldn't connect to irc.freenode.net:6667: [Errno 111] Connection refused
INFO:bearded-potato-donger:Connecting to irc.freenode.net:6667
ERROR:bearded-potato-donger:Couldn't connect to irc.freenode.net:6667: [Errno 111] Connection refused
INFO:bearded-potato-donger:Connecting to irc.freenode.net:6667
ERROR:bearded-potato-donger:Couldn't connect to irc.freenode.net:6667: [Errno 111] Connection refused
INFO:bearded-potato-donger:Connecting to irc.freenode.net:6667
ERROR:bearded-potato-donger:Couldn't connect to irc.freenode.net:6667: [Errno 111] Connection refused
INFO:bearded-potato-donger:Connecting to irc.freenode.net:6667
ERROR:bearded-potato-donger:Couldn't connect to irc.freenode.net:6667: [Errno 111] Connection refused
INFO:bearded-potato-donger:Connecting to irc.freenode.net:6667
ERROR:bearded-potato-donger:Couldn't connect to irc.freenode.net:6667: [Errno 111] Connection refused
INFO:bearded-potato-donger:Connecting to irc.freenode.net:6667
ERROR:bearded-potato-donger:Couldn't connect to irc.freenode.net:6667: [Errno 111] Connection refused

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.